Question: 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:

COMPLETE THE FOLLOWING CODE IN JAVA ACCORDING TO INSTRUCTIONS AT END: publicOUTPUT FROM FIGURE 5:

class Car { /** * Instance variable for storing the type of

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

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!