Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions