Question: Please help and answer this in java :) Description: read user input from keyboard provide user choices with a menu use repetition statements use selection
Please help and answer this in java :)
Description:
read user input from keyboard provide user choices with a menu use repetition statements use selection statements override toString create a jar file that includes the Java source code
In this assignment I encourage you to work with a partner so you can help each other refresh concepts that have been covered in CSIS-1400. It is important to be responsive and that each partner contributes his/her fair share. If you have concerns about your partner bring it up as early as possible. First try to resolve the issue with your partner. If that is difficult talk to your instructure.
Each code file should include a comment on top that lists both students and the name of the assignment. Together write a program that keeps track of a list of items and that provides the user with a menu that allows the user
to add, remove, list items, etc. For more details read the instructions below.
Instructions:
Decide which items you would like to store in the list. (e.g. books, bikes, gemstones, etc.) It can by any thing but not cars (I used that for the example) and not people.
Create a class that represents the item you chose. Here are some requirements your class needs to fulfill:
It can not be cars or people (see above)
The class needs to have at least 3 attributes you are keeping track of (e.g. year, make, model)
It needs to have two additional fields:
o a unique id that cannot be changed once created (like a primary key in a database)
o a static count that is used to initialize the id with a unique number Notice: At this point, we have a total of at least 5 attributes
It needs a parameterized constructor. It allows the user to provide values for all the attributes you are keeping track of but not for the id nor for the count. (in our case that would be 3 parameters: year, make, and model) The constructor creates a unique id e.g. an 8 digit number for each item based on the static field count. (e.g. 12345678 + count++; In this example the smallest id would be 12345678)
It needs a getter for each of the fields except for the static count (in our case that would be 4 getters) The static count should not be exposed to another class. It is only used to initialize the unique id in the
constructor.
Hint: http://stackoverflow.com/questions/7221691/is-there-a-way-to-automatically-generate-getters-and-setters-in-eclipse It needs to override the method toString.
The method toString has no parameters and returns a string that represents an instance of the class. This string needs to include the values of all fields except for count (e.g. 2015 Honda Accord id: 12345679 ) Labels should be added when the value itself is not self-explanatory. (e.g. id)
Sample Output :
1. Display all items 2. Add an item 3. Find an item 4. Delete an item 5. Number of items in list 6. Exit
Enter your selection: 1
2011 Toyota Corolla id:12345678 2015 Honda Accord id:12345679 2008 Audi A4 id:12345680 2017 Tesla Model 3 id:12345681
1. Display all items 2. Add an item 3. Find an item 4. Delete an item 5. Number of items in list 6. Exit
Enter your selection: 5 Number of cars: 4
1. Display all items 2. Add an item 3. Find an item 4. Delete an item 5. Number of items in list 6. Exit
Enter your selection: 3 Id: 12345680
2008 Audi A4 id:12345680
1. Display all items 2. Add an item 3. Find an item 4. Delete an item 5. Number of items in list 6. Exit
Enter your selection: 4 Id: 12345680
2008 Audi A4 has been deleted 1. Display all items
2. Add an item 3. Find an item 4. Delete an item 5. Number of items in list 6. Exit Enter your selection: 2
Year: 2013 Make: Ford Model: Mustang
Instructions continued:
At this point you have one class that represents one item (e.g. Book, Bike, Gemstone, etc.). This class does not contain the list of items nor should it include any print statements. You still need at least one more class (optionally two) that include(s) the list of items, the menu with options, and the user communication (input / output)
Create one or two additional classes to do the following:
Declare an ArrayList of items ( each element in the list should be an instance of the new Java type you just wrote) Initialize the list with four different elements (hard coded).
Display a menu with the following choices until the user chooses to exit:
1. Display all items 2. Add an item 3. Find an item 4. Delete an item 5. Number of items in list 6. Exit
Enter your selection:
Important: replace the word item and items with the actual type you store in the list. (e.g. Display all cars)
Provide the functionality chosen by the user. Use private methods to print the menu and to display, find, add, or delete items. Using private methods in such a way structures the code and to makes the code more clear and easier to read. When the user wants to find or delete an item s/he should be prompted for the id number. If the user provides and id number that doesnt exist, an appropriate message should be displayed. (e.g. The id ... could not be found.) If the id number could be found the item information should be displayed as part of the response (e.g. 2015 Honda Accord id:12345679 if the item was found or 2015
Honda Accord has been deleted if it was deleted) If the user enters an invalid choice from the menu (e.g. 9) an
appropriate message should be printed (e.g. Enter a selection 1 - 6) If the user enters 6 a message should be printed before terminating the program (e.g. Good bye)
Below you can find a sample output. This sample is about cars. Your output needs show elements of the item type you chose above.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
