Menu

[Solved]Java Instructions Create Netbeans Project Following Characteristics Create Utility Class M Q37085281

java

Instructions

Create a NetBeans project with the following characteristics.
Create a “utility” class with methods getUserDouble() andgetUserInt() that takes a prompt and error message, both asStrings, and returns a double and int value respectively.  Addanother method getUserString() that takes a prompt and returns theString entered by the user.  In the getUserDouble(), read theinput from the user as a String and convert it withDouble.parseDouble().  In getUserInt(), useInteger.parseInt().
In a subpackage, create a class called Car with the followingattributes:

modelYear an int with allowed values from 1898 to thecurrent year +1

makeName String that cannot be null or empty

modelName String that cannot be null orempty

Add the accessors, mutators, toString() with all the attributes,and a constructor that requires a value for each attribute.
In the same subpackage, create a CarModelYearException class thatextends Exception.  Also in the same subpackage, create aCarValidator utility class with methods to test the constraints onall the attributes.  An invalid modelYear must throw a newCarModelYearException.  The validator methods for makeName andmodelName must throw an IllegalArgumentException if the values arenot valid.  Call these methods from the Car constructor andaccessors as appropriate.
In the main() logic, instantiate an ArrayList<Car>. Give the following menu options:

Show Cars from List

Add Car to List

Exit

The “Show Cars from List” logic will print all the Cars in theArrayList, or if the ArrayList is empty, it will print a messagestating so.
The “Add Car to List”  will use the user input utility methodsto get the model year, make, and model name for a Car. Instantiate the Car and add it to the ArrayList.  Be sure tohandle any Exceptions that arise from instantiating the Car!
The “Exit” logic will ask the user to confirm that they wish toleave the program.  If they respond “Y”, then the program willend, otherwise it will continue running.
Test your program by attempting to add Cars to the ArrayList, usingboth allowed and disallowed values.

Expert Answer


Answer to java Instructions Create a NetBeans project with the following characteristics. Create a “utility” class with methods ge… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *