Question: Hello guys, i'm experimenting and learning Java. This is beginner Java, please dont use advanced programming. I'm trying to create two java classes. One is

Hello guys, i'm experimenting and learning Java. This is beginner Java, please dont use advanced programming. I'm trying to create two java classes. One is named "Car" and the other is named "Garage".

The "Car" class contains "Make", "Model" and "Date" (the date is when the car was created).

The "Garage" class is suppose to store 10 cars. It needs to have a get and set method for storing the cars at positions 0 to 9. It also needs to have a remove function that needs to remove a car at a given position and also a clear function that needs to take out all the cars of the garage.

My garage specifications are:

public Garage() - this is my constructor and it needs to be empty.

public Car getCar(int pos) - a get method that needs to return the car if it's there at the specific position or null value.

pos is the position

public boolean setCar(int pos, Car car) - set method that needs set the car at a specific position and to return true if inside the range of 0-9 or false if outside this range.

public boolean removeCar(int pos) - it needs remove car at a specific position and to return true if it works or false if it's out of the range 0-9.

public void clear() - it needs to clear all the cars from the garage.

Also, can you please add some testing values in the main function in order to test them and see how it works.

I already completed the Car class but can you show me how to do the Garage class.

This is my Car class that i've created:

package car; public class Car {

private String mMake; private String mModel; private String mDate; public static void main(String[] args) {

} public Car(String make, String model, String date) { mMake = make; mModel = model; mDate = date; } public String getMake() { return mMake; } public String getModel() { return mModel; } public String getDate() { return mDate; } }

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!