Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

*Do not use the code that other Chegg users have submitted* Design classes vehicle, car, american_car, foreign_car, truck, and bicycle with ALL appropriate inheritances. vehicle

*Do not use the code that other Chegg users have submitted* Design classes vehicle, car, american_car, foreign_car, truck, and bicycle with ALL appropriate inheritances. vehicle is the parent because everything is a vehicle or a member of a descendant of vehicle. The design of the classes is VERY important. Each of these classes will be in the file with your nnumber class that has the main() method. Your code must override the toString method in each class to display ALL the relevant information from the record. Also design an application class (your nnumber class with a main) that tests your classes and processes a file of records. The file of data to be used will be constructed by me with the following format used (examples are here): I WILL USE NOTEPAD TO CONSTRUCT THE FILE. TEST WITH A FILE FROM NOTEPAD. vehicle owner's name (string) address (string) phone (string) email (string) car owner's name (string) address (string) phone (string) email (string) true or false for convertible (boolean) color (string) american car owner's name (string) address (string) phone (string) email (string) true or false for convertible (boolean) color (string) true or false for made in Detroit (boolean) true or false for union shop (boolean) foreign car owner's name (string) address (string) phone (string) email (string) true or false for convertible (boolean) color (string) country of manufacturer (string) import duty (float) bicycle owner's name (string) address (string) phone (string) email (string) # of speeds (int) truck owner's name (string) address (string) phone (string) email (string) # of tons (float) cost of truck (float) date purchased (format below in exmample) etc.....these records can appear in any order and there can be up to 200 of them. Records will have a blank line between them. You will need to use an array of vehicle to store the data. Here are some examples of data: foreign car aMarioy Mario's house (777) 777-7777 gmario@mario.com false black Italy 4415.91 truck aDougy Doug's house (123) 456-7890 hdoug@doug.com 30 61234.56 8/10/2003 vehicle aRobby Rob's house (987) 654-3210 irob@rob.com bicycle bTommy Tom's house (246) 810-1214 jtom@tom.com 7 truck bGeorge George's house (666) 666-6666 kgeorge@george.com 25 51234.56 12/4/2004 vehicle bTim Tim's house (111) 111-1111 tim@tim.com bicycle bJim Jim's house (555) 555-5555 Ajim@jim.com 5 american car bJohn John's house (888) 888-8888 Bjohn@john.com true green false true car cKen Ken's house (999) 999-9999 Cken@ken.com false orange foreign car cMario Mario's house (777) 777-7777 Dmario@mario.com false black Italy 4415.91 truck zDoug Doug's house (123) 456-7890 Edoug@doug.com 30 61234.56 8/10/2003 vehicle eRob Rob's house (987) 654-3210 Frob@rob.com bicycle fTom Tom's house (246) 810-1214 Gtom@tom.com 7 american car gSam Sam's house (333) 333-3333 Hsam@sam.com false blue true false Write an application class (your nnumber with a main) that reads a file (from the command line) and fills an array of type vehicle[] with new vehicle (params), new car (params), new american car (params) new foreign car(params) , new truck (params), new bicycle (params), etc.: the params depend on the first line that identifies each record. params is just a shorthand name for parameter list (the arguments to a method.) To get the file , in jGrasp you must click on the tab file/check run args, and then type the name of the file in the box at the top. I will test your program with my own file! You must not type in the name of the file in your code because it is only specified at run time. The name of the file in your code will be args[0] when you use public static void main(String[], args) throws FileNotFoundException . Because the input comes from the file instead of the keyboard you should be able to modify Scanner to deal with wrapping! Scanner x = new Scanner(new File(args[0])). Google "java scanner" to learn about Scanner and/or "java command line" to learn about args[0]. This information is located on pages 478-480 of Liang's 10th Edition. Print the output from each of the following calls: 1. Call a printAll method that can be passed an array of type vehicle[] and which prints each element of the array using the appropriate toString() methods. ArrayList is fine if you wish to use it. 2. Call a sort method that can be passed an array of type vehicle[] and which sorts the array by email addresses and prints the new sorted array using appropriate toString() methods. Any sort method is fine, but it should sort according to unicode (case sensitive, that is to say that all upper case is before any lower case)! 3. Call a method that prints the number of records. 4. Call a method that prints just the bicycles and trucks (from the sorted array using the appropriate toString() methods). 5. Call a method that prints the vehicles in area code 987. THERE ARE NO PROMPTS. JUST RUN THE PROGRAM. Be sure to declare variables as private, to extend all the classes appropriately, and to have the right constructors (using super where appropriate), and the getters and setters for ALL the variables. MUST SEND ALL THE OUTPUT FROM PRINTING TO THE CONSOLE, NOT TO A WINDOW. 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2005 For Windows Mobile Web Office And Database Applications Comprehensive

Authors: Gary B. Shelly, Thomas J. Cashman, Corinne Hoisington

1st Edition

0619254823, 978-0619254827

More Books

Students also viewed these Databases questions