Answered step by step
Verified Expert Solution
Question
1 Approved Answer
How to do Task 4 in Java ?? Cvertiryuu UUTISITE Tanerges tuuay, yuu SIVUlu yet retuva Uryuur compettu UIVIL Crassuraylar before you leave. This will
How to do Task 4 in Java ??
Cvertiryuu UUTISITE Tanerges tuuay, yuu SIVUlu yet retuva Uryuur compettu UIVIL Crassuraylar before you leave. This will mean you can work at home without coding up a poorly-designed solution. Task 2. Start the implementation Even when you have a complete design, it is usually a good idea to implement and test your program bit by bit. Create a new project called Auto Showroom using your preferred IDE (We recommend Intellij IDEA) and add the following calss. public class Auto Showroom { public void printStatus() { System.out.println("Welcome to FIT2099 Showroom"); System.out.println("Thank you for visiting FIT2099 Showroom"); } As you can see, all the class can currently do is print a welcome message. Once you have added the class to your project, create a new Auto ShowroomDriver class. This class should contain only a main(...) method that creates a Auto Showroom object and calls its printStatus method. Run your program and confirm that it works as expected. If you have questions or difficulties then, make an ED discussion form post, attend a consultation, or ask your lab tutor. Task 3. Extending the implementation - adding a Car class The system needs a Car class. Each Car object must know its make (e.g. "BMW") and its model (e.g. "X7"). The Car class should also have a getCarDescription() method, that returns a string of the concatenated car maker and model, e.g. BMW X7". To test your Car class, add some code to Auto Showroon.printStatus() that . creates a Car object and prints its description using the getCarDescription() method. . class The system needs a Car class. Each Car object must know its make (e.g. "BMW") and its model (e.g. "X7"). The Car class should also have a getCarDescription() method, that returns a string of the concatenated car maker and model, e.g. "BMW X7". To test your Car class, add some code to Auto Showroon.printStatus() that creates a Car object and prints its description using the getCarDescription() method. Confirm that your program is producing the correct output before proceeding to the next task. Task 4. Arrays of Cars Now, we would like the system to be able to handle an arbitrary number of Cars. Modify the Auto Showroom class so that instead of containing a single Car, it contains an array of Cars (Java array not ArrayList). Add two new methods, createCars() and displayCars(), to Auto Showroom. createCars() must create three new Car objects, add car maker and model to them, and store them in the array. displayCars() must display the descriptions for the cars, which you can generate by invoking getCarsDescription() on each of the cars in the array. Try to use a loop rather than repeated code, and try to avoid hardcoding the array length into displayCars. . Modify the printStatus() method to display the welcome message, call the createCars() method, call the displayCars() method, and then display the goodbye message. Expected output: Welcome to FIT2099 Showroom Car (1) Maker:BMW and Model:X7 Car (2) Maker:Audi and Model:A8 Car (3) Maker:Mercedes and Model: GLS Thank you for visiting FIT2099 Showroom CamScannerStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started