Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Java ParkingLot: This object should have AT LEAST 2 attributes: An array of ParkingSpace objects A value to denote how many of the available

In Java

ParkingLot:

This object should have AT LEAST 2 attributes:

An array of ParkingSpace objects

A value to denote how many of the available ParkingSpaces in the ParkingLot are full (MUST BE a percentage!)

Required methods:A constructor method which:

Takes in an integer to denote how many Auto ParkingSpaces to create in the ParkingLot

Takes in an integer to denote how many Bicycle ParkingSpaces to create in the ParkingLot

Updates the ParkingLot's array attribute to reflect this input

toString() method:Should create and return a String with information about:

Number of total ParkingSpaces in the ParkingLot

How full the ParkingLot is (displayed as a percentage)

A park() method which takes in an Auto and:

Attempts to locate an available Auto ParkingSpace

If such a ParkingSpace is found, the Auto should be parked the ParkingSpace and a true should be returned

If such a ParkingSpace is not currently available in the ParkingLot, a false should be returned

A park() method which takes in an Bicycle and:

Attempts to locate an available Bicycle ParkingSpace

If such a ParkingSpace is found, the Bicycle should be parked the ParkingSpace and a true should be returned

If such a ParkingSpace is not currently available in the ParkingLot, a false should be returned

A find() method which:

Takes in a String

Goes through the array of ParkingSpaces checking to see if the input String matches either:

The license plate of parked Autos

OR

The serialNumber of parked Bicycles

If a matching Auto or Bicycle is found, the matching Auto or Bicycle should be unparked from the ParkingSpace it is in and then returned.

If a a matching Auto or Bicycle is NOT found, a null should be returned.

NOTE: Since this method could return either an Auto or a Bicycle, the return time of this method should be Object

----------------------------------------------

The ParkingSpace object will need:

a new method called unpark() which will return whatever object is currently parked in the ParkingSpace.

a new attribute for storing an Object (the vehicle currently in the ParkingSpace OR a null)

a new method to return whatever Object is currently stored in the attribute listed above

modifications to the parkAuto() and parkBicycle() methods to also store the input object into the ParkingSpace's new Object attribute

--------------------------------------------

Create/Modify a driver so that:

A ParkingLot able to hold 10 Autos and 5 Bicycles is created

Use a Loop to create and park 11 Autos. As each Auto is parked, note if the parking was successful (10 should be, 1 should not be!)

Print out the status of the ParkingLot (should be at 66.7% capacity...)

Use a Loop to create and park 6 Bicycles. As each Bicycle is parked, note if the parking was successful (5 should be, 1 should not be!)

Print out the status of the ParkingLot (should be at 100% capacity...)

Remove one of the objects from the ParkingLot by passing in a serial number or license plate you know should be in the Parking Lot.

Print out the returned object

Print out the status of the Parking Lot (Should be at 93.3% capacity...)

Try removing something from the ParkingLot that SHOULD NOT be in the ParkingLot. Use an if statement to check and print if you got a null back (which you should have)

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

Step: 3

blur-text-image

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

Data And Information Quality Dimensions, Principles And Techniques

Authors: Carlo Batini, Monica Scannapieco

1st Edition

3319241060, 9783319241067

More Books

Students also viewed these Databases questions