Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Java Data Structures - Retired Efficiency! Menu UI

Wouldn't numeric prompts be more user friendly? How will the data be persisted?

I think that a menu system with numeric options is easier, e.g

1 - Add new song 2- Edit song 3 - Remove song 4 - Admin tools 5 - Quit

Also, what if the user doesn't enter anything or a bunch of spaces only? Will that crash the application? Shouldn't some form of validation be performed?

A Karaoke machine that loses its data each time the application is exited or crashes seems less useful than one that stores and retrieves data. Can this app possibly use the Serializable methods of writeObject on an ObjectOutputStream and readObject on an ObjectInputStream?

Thanks

Dylan Carter
Dylan Carter
4,780 Points

I tried the Integer way and I got it to work but when I selected a valid choice (1 for add 2 for quit) it would go to the default of the switch and say either 49 or 48 wasn't an acceptable response or something of that nature. I did with with the Integer class instead of int that could be why may retry it with that and see what happens.

1 Answer

Rafael Valera
Rafael Valera
8,401 Points

Hi, Adiv

For input validation read about exception hadling.... Certaninly your app will crash if unexpected data is introduced. https://docs.oracle.com/javase/tutorial/essential/exceptions/