https://github.com/saitejesh12345/oops-vechile-assignment
https://github.com/saitejesh12345/oops-vechile-assignment
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/saitejesh12345/oops-vechile-assignment
- Owner: saitejesh12345
- Created: 2023-11-07T08:19:41.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2023-11-07T12:58:27.000Z (about 2 years ago)
- Last Synced: 2025-01-04T08:48:11.528Z (about 1 year ago)
- Language: Java
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: ReadMe.md
Awesome Lists containing this project
README
Vehicles
The following project contains two subtasks:
Subtask 1: You are given the classes Vehicle, Car, and F1. Complete the driver code of each of these classes.
Subtask 2: You are given the interface WaterVehicle. Construct a new class Boat (with exactly the same and member variables as given below).
The details of the classes that constitute the project are:
Vehicle: name, currentSpeed, currentDirection
constructor: given the name of the vehicle, initialize speed and direction as 0.
move(speed, direction): set the current speed and direction
steer(direction): Add direction to the currentDirection
stop(): Stop the car by setting current speed to 0
Car: extends Vehicle
constructor: initialize the variables using parameters and set currentGear as 1.
changeGear(newGear): set the current gear to newGear parameter.
changeSpeed(newSpeed, newDirection): set the speed and direction using move().
F1: extends Car
accelerate(rate): add rate to the current speed and change the gear accordingly
Boat: implements WaterVehicle interface
Has following member variables: a. name : of String type b. capacity : of int type
Return name and capacity in getVehicleName and getVehicleCapacity respectively.
Note:
Make sure that the class names are exactly the same.