Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need just question 6 Given the following code which displays the following GUI application: primarystage. settitle ( _ pane. addColumn (0, plateNol, brandt, ratet,

I need just question 6 image text in transcribed
image text in transcribed
Given the following code which displays the following GUI application: primarystage. settitle ( _ pane. addColumn (0, plateNol, brandt, ratet, addB) : pane. addColumn (1, plateNoTF, brandTF, rateTF); Scene scene = new Scene (pane); primarystage . setscene (scene); primarystage. show () 7 L/Missing Code (2): clicking on the button 1. Complete the first missing code to initialize the Ul controls. 2. Complete the second missing code such that when the user fills the required information and clicks on the button "Add Car", a Car will be added to myCompany. 1. Write the class Car which includes: a) 3 attributes: unique number plate (e.g. ABC123), brand (e.g. Toyota) and rental rate (e.g. \$20). b) a zero-arg constructor and a mutli-arg constructor. c) Getter for brand attribute and setter for rate attribute. d) tostring() method which overrides the Object's tostring() method. e) equals() method which overrides the Object's equals() method. f) compareTo() method which implements the Comparable's compareTo() method. You should use the number plate only in the comparison. 2. Write the class Company which includes: (add the necessary import statements) a) 2 attributes: Company name and ArrayList of Cars. b) one-arg constructor that accepts the Company name as an argument and create a new empty Arraylist of Cars. c) method addCar() that accepts a Car object as an argument and add it to the ArrayList with a confirmation message. It is not allowed to add the same Car twice and in this case an error message should be displayed. d) method brandFrequency() that accepts a brand (e.g. BMW) as an argument and returns how many cars in the company of this brand. e) method savelntoFile() which accepts a file name as an argument. It stores the Company name and information of all Cars in this file (each Car in a different line). For cars, they should be sorted in ascending order (according to the number plate). 3. Write a code to test your classes by performing the following tasks: a) create a Company object called myCompany where the Company name is "Car 4 u". . [5 marks] b) create 2 Cars and add them to myCompany using the method addCar() c) print how many cars of brand BMW are in the Company by calling the method brandFrequency() d) call the method savelntoFile() to save the required information

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

Web Database Development Step By Step

Authors: Jim Buyens

1st Edition

0735609667, 978-0735609662

More Books

Students also viewed these Databases questions