+ 1

Where to store my pizza? Answer: In a delicious database!

Working on a simple Java program for ordering pizza and could use some direction on storing the orders. My program loads a menu, asks for a name, prompts user for pizza values (crust size, toppings, etc.), passes those values to a constructor that creates the pizza, tracks the number of pizzas made, assigns order numbers, and gives user option to create new order (Y/N, with 'Y' running through the creation process again and 'N' exiting program). There are static fields that increment and track number of pizzas made but as soon as the user exits the program the counter resets to zero. I'm still learning Java, so my IO and database skills are limited. Wondering if I can/should write the orders to a text file, then maybe read from file to set/adjust my static counter fields when the program starts again? Hope this makes sense. Again, don't really have code to share, just in need of a little direction to explore solutions. Thanks 😊

22nd Oct 2019, 5:31 AM
will
will - avatar
3 Respuestas
+ 2
to store values even if program is terminated you can either use a database (more secure) or a text file (not recommended for real life apps). The reason text files are not recommended, anyone can open the directory and modify the info directly but its an easy way out if you're just testing things.
22nd Oct 2019, 5:37 AM
George Samanlian
+ 1
try to store in a database. its very useful in the future. You can use some online database like H2 , or you can run Mysql in your computer. Both of them are open source.
23rd Oct 2019, 6:04 AM
Sai Ram
0
Thanks, George Samanlian, I'm about ready to learn Java databases anyway, so that might be a good next step. My program is simple, so it takes a bunch of inputs and spits back an order receipt (order details, order number, timestamp). I know the amount of user data will grow as I continue to work on the program, so even if a text file did work now it would turn ugly fast with all that data stored. Especially if I wanted to do more than just print.
22nd Oct 2019, 5:47 AM
will
will - avatar