Answered step by step
Verified Expert Solution
Question
00
1 Approved Answer
Create a test class that will create a train object of each constructor definition, for 2 of the trains invoke the drive and stopping methods.
Create a "test" class that will create a train object of each constructor definition, for 2 of the trains invoke the drive and stopping methods. On the train that is created with all the types of cars, invoke at least 1 method per car. Submit the java files on the cs server For each state, implement the accessors and mutators For each car object, implement a default (no-args) constructor and an explicit constructor Train object: States: freightCar: FreightCar o passengerCar: PassengerCar o engineCar: EngineCar caboose: Caboose o starting Point: String = "Nacogdoches, TX" o endpoint: String = "Garrison, TX" o at Station: String = "Nacogdoches, TX" o nextStation: String = "Garrison, TX" O speed: int = 0 o direction: String = "rest" Behaviors: Default (no-args) constructor that creates a train with only 1 Engine Car o Explicit constructor that accepts FreightCar, Engine Car, starting point endpoint, at Station, nextStation o Explicit constructor that accepts PassengerCar, Engine Car, starting point endpoint, at Station, nextStation o Explicit constructor that accepts Engine Car, Caboose, starting point endpoint, at Station, nextStation Explicit constructor that accepts FreightCar, Caboose, EngineCar, starting point. endpoint, atStation, nextStation Explicit constructor that accepts PassengerCar, Caboose, Engine Car, starting Point, endpoint, at Station, nextStation o Explicit constructor that accepts FreightCar, PassengerCar, Caboose, Engine Car, starting Point, endpoint, atStation, nextStation o drive, it sets the engine Car's move in forward motion; accepts nothing returns nothing o reverse, it sets the engineCar's move in backward motion; accepts nothing, returns nothing o stopping, it engages the engineCar's stop method: accepts nothing, returns nothing o at Station, the engine Car's move is at rest: accepts nothing, returns nothing Freight car object: States o cargo Empty: boolean = true cargo Description: String = null Passenger car object: States howMany Seats: int = 20 Engine car object: States: o engine Type: String = "diesel-electric" engine Speed: int = 0 o maxEngine Speed: int = 50 o direction OfMovement: String = "rest" Behaviors: (in addition to the constructors, accessors, and mutators) o move, accepts the direction OfMovement . depending on the direction OfMovement, the engine Speed will increase by l to the maxEngine Speed, if the directionOfMovement is at rest, speed is not increased stop, decreases engine Speed by 1 until it is at zero Caboose object: . states: o manned: boolean = false
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered 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