Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

COMPLETE THE FOLLOWING CODE IN JAVA ACCORDING TO INSTRUCTIONS AT END: public class Car { /** * Instance variable for storing the type of the

COMPLETE THE FOLLOWING CODE IN JAVA ACCORDING TO INSTRUCTIONS AT END:

public class Car { /** * Instance variable for storing the type of the car */ private CarType type; /** * Instance variable for storing the car plate number */ private String plateNum; /** * @return the type of this car */ public CarType getType() { // WRITE YOUR CODE HERE! return null; // REMOVE THIS STATEMENT AFTER IMPLEMENTING THIS METHOD } /** * Sets the type of the car * * @param type is the car type */ public void setType(CarType type) { // WRITE YOUR CODE HERE! } /** * @return the plate number */ public String getPlateNum() { // WRITE YOUR CODE HERE! return null; // REMOVE THIS STATEMENT AFTER IMPLEMENTING THIS METHOD } /** * Sets the car plate number * * @param plateNum is the car plate number */ public void setPlateNum(String plateNum) { // WRITE YOUR CODE HERE! } /** * Constructor for Car * * @param type is the type of the car * @param plateNum is the car plate number */ public Car(CarType type, String plateNum) { // WRITE YOUR CODE HERE! } /** * Returns a string representation of the car */ public String toString() { // NOTE: The implementation of this method is complete. You do NOT need to // change it for the assignment. return Util.getLabelByCarType(type) + '(' + plateNum + ')'; } }

INSTRUCTIONS:

You need to complete the setters, getters, and the constructor in the Car class.

Example input:

image text in transcribedOUTPUT FROM FIGURE 5:

image text in transcribed

THANK YOU

S,S,NL,L,EL,N,N###0,1,L,C12,2,E,C21,1,S,C31,1,L,C43,3,S,C5 Figure 5: Example Input with Errors $ java ParkingLot Please enter the name of the file to process: parking-with-errors.inf Car L(C1) cannot be parked at (0,1) Car E(C2) cannot be parked at (2,2) Car L(C4) cannot be parked at (1,1) Car S(C5) cannot be parked at (3,3) Total number of parkable spots (capacity): 6 Number of cars currently parked in the lot: 1 ==== Lot Design ==== S,S,N L,L,E L,N,N ==== Parking 0ccupancy ==== (0,0) : Unoccupied (0,1): Unoccupied (0,2) : Unoccupied (1,0) : Unoccupied (1,1):S(C3) (1,2) : Unoccupied (2,0) : Unoccupied (2,1) : Unoccupied (2,2) : Unoccupied $

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

Students also viewed these Databases questions