Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need help with Car.java I ve attached the instructions as well as the errors I m receiving. PLEASE provide corrected codes if possible. My
I need help with Car.java
Ive attached the instructions as well as the errors Im receiving.
PLEASE provide corrected codes if possible.
My code:
public class Car extends Vehicle implements Comparable, Announcements
private int numDoors;
private int numWindows;
public Carint numDoors, int numWindows
super;
this.numDoors numDoors;
this.numWindows numWindows;
public Carint numDoors, int numWindows, int numSeatsPerRow
super numSeatsPerRow;
this.numDoors numDoors;
this.numWindows numWindows;
public Carint numDoors, int numWindows, int numSeatsPerRow
supernumSeatsPerRow;
this.numDoors numDoors;
this.numWindows numWindows;
public Carint numDoors, int numWindows, Person driver, int numSeatsPerRow
superdriver numSeatsPerRow;
this.numDoors numDoors;
this.numWindows numWindows;
public boolean canOpenDoorPerson p
ifthisnumDoors super.numberOfRows
Person person super.getPersonInSeat super.getPeopleInRowlength;
ifperson null && person.getAge
return true;
return false;
public boolean canOpenWindowPerson p
ifthisnumWindows super.numberOfRows
Person person super.getPersonInSeat super.getPeopleInRowlength;
ifperson null && person.getAge
return true;
return false;
public int getNumDoors
return numDoors;
public int getNumWindows
return numWindows;
public boolean equalsObject o
Car car Car o;
ifcargetNumDoors this.numDoors && car.getNumWindows this.numWindows
ifcarnumberOfRows this.numberOfRows && car.maxSeatsPerRow this.maxSeatsPerRow
forint i ; i car.numberOfRows; i
ifcargetNumberOfPeopleInRowi this.getNumberOfPeopleInRowi
return false;
return true;
return false;
public String toString
String carDetails ;
carDetails String.formatnumber of doors d this.numDoors;
carDetails String.format number of windows d this.numWindows;
carDetails String.format number of rows d super.numberOfRows;
carDetails seats per row ;
forint i ; i super.numberOfRows;i
Person p super.getPeopleInRowi;
carDetails plength;
ifi super.numberOfRows
carDetails ;
carDetails ;
forint i ; i super.numberOfRows; i
Person p super.getPeopleInRowi;
carDetails ;
forint j ; j plength; j
ifpj null
ifj
carDetails ;
carDetails pjgetName;
carDetails ;
return carDetails;
public int compareToCar c
Person p cpersonsOnBoard;
Person p this.personsOnBoard;
int totalNumberOfSeats ;
int totalNumberOfSeatsPassed ;
forint i ; i plength; i
totalNumberOfSeats pilength;
forint j ; j plength; j
totalNumberOfSeatsPassed pjlength;
iftotalNumberOfSeats totalNumberOfSeatsPassed
return ;
else
iftotalNumberOfSeats totalNumberOfSeatsPassed
return ;
else
return ;
@Override
public String departure
return "All Aboard
;
@Override
public String arrival
return "Everyone Out
;
@Override
public String doNotDisturbTheDriver
return No Breakseat Driving
;
@Override
public boolean loadPassengerPerson p
ifpgetAge && pgetHeight
forint i ; i super.numberOfRows; i
ifsupergetNumberOfAvailableSeatsInRowi
super.personsOnBoardisupergetNumberOfPeopleInRowi p;
return true;
return false;
@Override
public int loadPassengersPerson peeps
int count ;
forint i ; i peeps.length; i
ifthisloadPassengerpeepsi true
count;
return count;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started