Task 2: Vehicles and Stations Now we want to test our docking interface, but first we want to define an abstract class for our vehicles from which we will model all of our designs after. 1

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Task 2: Vehicles and Stations
Now we want to test our docking interface, but first we want to define an abstract
class for our vehicles from which we will model all of our designs after.
Instructions
1. Create an abstract class called Vehicle that has the following properties:
. a private attribute called name of type String
a protected attribute called chargeRemaining of type double
• a protected attribute called maxChargeCapacity of type double
appropriate getters/setters for the attributes.
●
an abstract method called print Info
an abstract method called calculateTotalCharge Needed that re-
turns a double
2. Create a class called ChargingStation that uses the Dockable interface
3. Make sure that the ChargingStation class has the following properties:
. a private array of Vehicle objects that represents the docked vehicles
- The index of each object represents its docking number/bay
4. Implement all of the necessary methods in ChargingStation
• canDock returns true if there is space for a vehicle to dock or false if
the docking array is full
dock must take a Vehicle as a parameter and add it to the array of
docked vehicles:
- if the vehicle is added to the array, return the index (charging
port number) of the vehicle
1
.
●
- if the vehicle cannot be added to the array return -1
calculateTotalCharge Needed must return the charge needed of the
all of the docked vehicles
- if the ChargingStation has one vehicle docked that has a maxi-
mum charge capacity of 500 kAH with a chargeRemaining of 200
kAH then calculateTotalCharge Needed should return 300
- if the Charging Station has two vehicles docked that both have
a maximum charge capacity of 500 kAH with a chargeRemaining
of 100 kAH then calculateTotal Charge Needed should return
800
• print Info must print out the name of the ChargingStation and a
list of the docked vehicles (see sample output)
- if no vehicles are docked then it should print none
5. Create a subclass of Vehicle called Test Vehicle that implements the
abstract methods of the Vehicle class:
• print Info should print out the name and weight of the Test Vehicle
• calculateTotalCharge Needed should return the maxCharge Capacity
less the chargeRemaining of the Test Vehicle
Hint: the docking array may be partially filled.
Transcribed Image Text:Task 2: Vehicles and Stations Now we want to test our docking interface, but first we want to define an abstract class for our vehicles from which we will model all of our designs after. Instructions 1. Create an abstract class called Vehicle that has the following properties: . a private attribute called name of type String a protected attribute called chargeRemaining of type double • a protected attribute called maxChargeCapacity of type double appropriate getters/setters for the attributes. ● an abstract method called print Info an abstract method called calculateTotalCharge Needed that re- turns a double 2. Create a class called ChargingStation that uses the Dockable interface 3. Make sure that the ChargingStation class has the following properties: . a private array of Vehicle objects that represents the docked vehicles - The index of each object represents its docking number/bay 4. Implement all of the necessary methods in ChargingStation • canDock returns true if there is space for a vehicle to dock or false if the docking array is full dock must take a Vehicle as a parameter and add it to the array of docked vehicles: - if the vehicle is added to the array, return the index (charging port number) of the vehicle 1 . ● - if the vehicle cannot be added to the array return -1 calculateTotalCharge Needed must return the charge needed of the all of the docked vehicles - if the ChargingStation has one vehicle docked that has a maxi- mum charge capacity of 500 kAH with a chargeRemaining of 200 kAH then calculateTotalCharge Needed should return 300 - if the Charging Station has two vehicles docked that both have a maximum charge capacity of 500 kAH with a chargeRemaining of 100 kAH then calculateTotal Charge Needed should return 800 • print Info must print out the name of the ChargingStation and a list of the docked vehicles (see sample output) - if no vehicles are docked then it should print none 5. Create a subclass of Vehicle called Test Vehicle that implements the abstract methods of the Vehicle class: • print Info should print out the name and weight of the Test Vehicle • calculateTotalCharge Needed should return the maxCharge Capacity less the chargeRemaining of the Test Vehicle Hint: the docking array may be partially filled.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY