Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

COMPLETE THE TASKS ASKED OF YOU IN THE CODE IN JAVA: class SubwayYard { String location; String[] linesServiced; int numCarsCleaned; int numCarAcsFixed; SubwayYard (String loc,

COMPLETE THE TASKS ASKED OF YOU IN THE CODE IN JAVA:

class SubwayYard {

String location;

String[] linesServiced;

int numCarsCleaned;

int numCarAcsFixed;

SubwayYard (String loc, String[] lines) {

location = loc;

// Make our own copy of the lines array

// so it doesn't change from under our feet (wheels?)

linesServiced = lines.clone();

numCarsCleaned = 0;

numCarAcsFixed = 0;

}

// Returns true if a given subway car can be serviced

// at this yard.

boolean canServiceCar(SubwayCar car) {

for (String line : linesServiced) {

if (line.equals(car.line))

return true;

}

return false;

}

// Cleans a subway car.

void cleanCar(SubwayCar car) {

if (canServiceCar(car) && !car.isClean) {

car.isClean = true;

numCarsCleaned++;

}

}

// Fixes the AC in a subway car.

void fixAc(SubwayCar car) {

// TODO #1: Fill me in!

}

// TODO #2: Write a method cleanTrain that takes

// an array of subway cars and "cleans" them

// (if they can be serviced by this yard). Don't

// forget to properly update numCarsCleaned!

// TODO #3 and #4 are in Main.java

// TODO #5: Write a method fixTrainAcs that takes

// an array of subway cars and fixes their ACs

// (if they can be serviced by this yard). Don't

// forget to properly update numCarAcsFixed!

// TODO #7: Write a method serviceTrain that takes

// an array of subway cars, cleans them and fixes their ACs.

}

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

Database Design Application And Administration

Authors: Michael Mannino, Michael V. Mannino

2nd Edition

0072880678, 9780072880670

More Books

Students also viewed these Databases questions

Question

What is managerial accounting?

Answered: 1 week ago