Question: 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

 2. Write the class Company which includes: (add the necessary import

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)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!