subject

Use BlueJ to write a program that reads a sequence of data for several car objects from an input file. It stores the data in an ArrayList list. Program should work for input file containing info for any number of cars. (You should not assume that it will always be seven lines in the input file). Use notepad to create input file "inData. txt". File should be stored in the same folder where all files from BlueJ for this program are located.

Class Car describes one car object and has variables vin, make, model all of String type, cost of type double, and year of int type. Variable vin is vehicle identification number and consist of digits and letters . In addition, class Car has methods:

public double getCost() // returns car’s cost

public String getMake() // returns car’s make

public boolean isExpensive() // returns true if car has cost above 30000 and false

//otherwise

public boolean isAntique() // returns true if car’s has above 50 years, and false

// otherwise

public String toString() // returns string with all car’s data in one line

// separated by tabs.

Design class CarList that has instance variable list of ArrayList type. Variable list is initialized in the constructor by reading data for each car from an input file. Each line of input file "inData. txt" has vin, make, model, cost, and year data in this order, and separated by a space. The data for the first five cars in the input file should be as follows:

1234567CS2 Subaru Impreza 27000 2017

1233219CS2 Toyota Camry 31000 2010

9876543CS2 Ford Mustang 51000 1968

3456789CS2 Toyota Tercel 20000 2004

4567890CS2 Crysler Royal 11000 1951

Add remaining two rows for the two additional cars of your choice.

Class CarList also has the following methods:

public void printList() // Prints title and list of all cars (each row prints one car)
public void printExpensiveCars() //Prints "List of expensive cars:" followed by
// list of expensive cars (one car per row)

public Car cheapestCar() // Method returns Car object with lowest cost.
public int countCarsWithModel(String model) // Method accept model and
// returns count of cars with given model.

//Method antiqueCarList is extra credit.

public ArrayList antiqueCarList () // Returns ArrayList of all antique
//cars from the list.

The last three methods just return the specified data type. Do not print anything within those methods. Just return result, and have explanation printed at the place where those methods are invoked.

Class TestCarList will have main method. In it, instantiate an object from CarList class and use it to invoke each of the five methods from CarList class.

Do not forget to append throws IOException to the constructor of CarList class and main method header in class TestCarList. In addition, you have to provide

import java. io.*;

import java. util.*;

in order to use Scanner and ArrayList classes from Java.

SUBMIT a single word or PDF document named p1yourLastNameCS152 with the following:

Your name, class section and project number and date of submission in the upper left corner
Copy of the code for each class in separate rectangle (table of size 1x1 with single cell)
Copy of your input file
Picture of program run from BlueJ.

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 06:30, arguellesjavier15
Who can provide you with a new password when you have forgotten your old one? your provide you with a new password in case you forget your old one.
Answers: 3
image
Computers and Technology, 23.06.2019 19:50, Aprillove7939
Which feature is selected to practice and save the timing of a presentation
Answers: 1
image
Computers and Technology, 23.06.2019 20:30, lucywood2024
What is the biggest difference between section breaks and regular page breaks
Answers: 1
image
Computers and Technology, 24.06.2019 13:50, Estefaniamarilicolin
What does code do? a creates a text box that says "solid black" b creates a black border of any width c creates a black border 1 pixel wide
Answers: 1
You know the right answer?
Use BlueJ to write a program that reads a sequence of data for several car objects from an input fil...

Questions in other subjects:

Konu
History, 09.10.2019 10:30
Konu
History, 09.10.2019 10:30