The Car and Tire classes are as given below. Write class called Classic1234 that does the following:
Question:
The Car and Tire classes are as given below. Write class called Classic1234 that does the following:
Ask the user how many cars they want to store (numCars). Then make random cars. This is to be done in the following fashion:
Use methods to fill two ArrayLists with car models and car colours of your choice (e.g., "Ferrari" could be a model and "Pink" could be a colour). Make sure there are at least 4 models and 4 colours. Create numCars cars with a random selection of model and colour from the lists you made, random mileage in the 0-400000 (inclusive) range, and random year in the range 1980-2022 (inclusive).
Create two list of tires - goodTires and badTires, and fill them in with 4 of the same tires (your choice of parameter values here). Add tires to every car. Each car should have a 1/3 chance of having the badTires and a 2/3 chance of having the goodTires.
Print all the cars.
Update the mileage on each car to have 50-200 (inclusive) more miles. "Paint" every second car black and every second car white (it does not matter which colour you begin with). Reduce the diameter of each tire by a random number between 1 and 3, inclusive.
Ask the user to provide a car number to delete, between 1 and the number of cars you are storing. Ensure that they enter a number in that range. Delete the car they specify (keeping in mind they start their list at 1, not 0).
Print all the cars
------------------------------------------------ import java.util.ArrayList;
public class Car { private String model; private int mileage; private int year; private String colour; ArrayList
public class Tire { private String company, model; private int diameter; private double roundness; public Tire(String company, String model, int diameter, double roundness) { this.company = company; this.model = model; this.diameter = diameter; this.roundness = roundness; } public Tire() { company = ""; model = ""; diameter = 0; roundness = 0; } public double getRoundness(){return roundness;} public int getDiameter(){return diameter;} public String getModel(){return model;} public String getCompany(){return company;} public void setRoundness(double r){roundness = r;} public void setDiameter(int d){diameter = d;} public void setModel(String m){model = m;} public void setCompany(String c){company = c;} public void reduceRoundness(double r){roundness -= r;} public void reduceDiameter(int d){diameter-=d;} public String toString() { String toReturn = ""; toReturn = toReturn + company + ":" + model + " with diameter " + diameter + " inches and roundness " + roundness; return toReturn; } }
//company //make //diameter //fr //vr
Organizational Behaviour Concepts Controversies Applications
ISBN: 978-0132310314
6th Canadian Edition
Authors: Nancy Langton, Stephen P. Robbins, Timothy A. Judge, Katherine Breward