Question: Consider having the following class: class Car { private String brand; private double price; public Device ( String newBrand, double newPrice ) { brand =

Consider having the following class:
class Car{
private String brand;
private double price;
public Device(String newBrand, double newPrice){
brand = newBrand;
price = newPrice;
}
public String getBrand(){
return brand;
}
public double getPrice(){
return price; }
}
Write a class called Exhibition that have the following data members: current : integer number represent the current number of devices in the laboratory. cars: an array of type Car. name: a string represent the name of the laboratory. Also, the class Exhibition, have the following methods: constructor : a constructor that take as a parameter a name for the library (newName) and an integer number n represent the size of the array to initialise the array. Note the method should set the current to zero. add: The method take as a parameter new car information (brand and price) and create a new car object, add it to the array cars and return true. Note, the method should not add the device if the devices array is full and return false. highestCar : The method should print the name and price of the device with highest price. countOverPricedCar : The method should return the count of the devices that are they are prices are over 100. Write a main method that do the following: Create an object of type Device, have the following data : name : Bahrain and n=3 Add to three devices as follow using the add method: Car brand : A, Price =1 Car brand : B, Price =150 Car brand : C, Price =200 Call the method highestCar to print its results. Call the method countOverPricedCar and print the results.

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 Accounting Questions!