Inspiration

All the world's particles and possibilities lead me to creating this. This project shows just a glimpse of the possibilities we can have by embracing functions that write themselves sort of like macros, but this program writes and runs while running. The project shows show the educational showcases that we can teach and can create.

What it does

HARDCODES ITSELF!! It takes a simple equation as input from the user, and then it calculates and writes a complete new .java class to hardcode that equation. That new class is then run to show the output!

How we built it

Java for the entire backend where it hardcodes itself and Java + JavaFX for the front end of the calculator.

Challenges I ran into

Connecting the backend to the front end. The output from the new hardcoded file could not be read from the frontend due to the necessity of static and global variables which were not possible for the JavaFX components. This was avoided by simply using a text file to pass information. Writing and running the new file. When running, the file needed to open up new threads to run, and this often got mixed up with the timing of the already running program. This was solved using process.waitFor() to allow the program to wait for the new process to finish running.

Accomplishments that we're proud of

The beautiful calculator UI, and being able to connect the frontend, backend, and being able to make the program write itself.

What we learned

How to use the PrintWriter class and more about JavaFX! The PrintWriter class was really interesting to navigate. It was really cool to see the possibilities of using a text writer to write, compile, and run an entire class within a program. I also loved working with the different types of components in JavaFX.

What's next for Hardcoded Calculator Calculator

A history page where you can see previous calculations, the ability to have more than just two values and one operation in a single equation, and more optimizations! The ability of a program writing other classes can also be implemented in future projects and maybe even within the calculator!

Built With

Share this project:

Updates