Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions

Question

=+ Why do some seem like a personalized, individual message?

Answered: 1 week ago