Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Vehicle part 3. This task has the following elements that are relevant to the learning outcomes of this module: - be able to define common

Vehicle part 3.

This task has the following elements that are relevant to the learning outcomes of this module: - be able to define common behavior for objects using interface - be able to define interfaces and classes that implement these - have knowledge of differences and differences between specific & abstract classes and interfaces - have knowledge of version control systems with special focus on GIT - could use the most common GIT methods in connection with program development You will continue to develop a console-based system that records vehicle information. Now let the Vehicle implement a Driveable interface that defines some constants and methods (see below). This task constitutes the third part of the GIT task and will be developed in branch "part3" remember to push it to your repository and then merge the master with it before continuing with the next task. The program should be developed gradually and in the third section you will: Vehicle: Implementable Driveable interface. Implement the stop () method defined in Driveable, it should set speed to 0 and print a message about it to the console. Car and Bicycle: They will implement the two other methods, accelerate (double factor) and breaks (double factor). factor defines how fast the vehicle accelerates or stops, but it has different effects. Car: If the car is at rest and starts to accelerate then it will get a speed equal to: 0.5 * factor, otherwise it will get speed equal to: speed * factor. The speed of car cannot exceed the speed defined in MAX_SPEED_CAR. When the car stops, it will get speed equal to: speed / factor no matter how fast it had moved before. Bicycle: If the bike is at rest and starts to accelerate then it will get a speed equal to: 0.3 * factor, otherwise it will get speed equal to: speed * 0.5 * factor. The speed of the bike cannot exceed the speed defined in MAX_SPEED_BIKE. When the bike stops it will get speed equal to: speed / (factor * 0.5) no matter how fast it had moved before. Both classes will also print the speed of the vehicle after it has accelerated / stopped. TestVehicles: Must get an additional choice "Test driveable interface" to test methods defined in Driveable. This test should preferably be hard-coded, it creates a new Car and Bicycle object, they accelerate, stop them a bit and stop them altogether.

Example of the application's print is:

1 ................................... New car 2 ........... .................... New bicycle 3 ...................... Find vehicle by name 4 .............. Show data about all vehicles 5 ....... Change direction of a given vehicle 6 ................ ......... Test clone method 7 .................. Test driveable interface 8 ............... ............... Exit program ............................. Your choice? 7 Car: Vehicle accelerated to: 5.00 km / h Vehicle accelerated to: 250.00 km / h Vehicle slowed down to: 0.25 km / h Vehicle stops Bicycle: Vehicle accelerated to: 3.00 km / h Vehicle accelerated to: 100.00 km / h Vehicle slowed down to: 0.20 km / h Vehicle stops

Driveable Interface:

public interface Driveable { double MAX_SPEED_CAR = 250.00 ; double MAX_SPEED_BIKE = 100.00 ; void accelerate ( int speed factor ) ; void breaks ( int speed factor ) ; void stop () ; } 

UML Chart for Class:

image text in transcribed

CVehicle Cloneable Driveable colour name serialNr model StringMAX SPEED_CAR double StringMAX SPEED_BIKE double vold void void Comparable compareTo(T) int accelerate(int) intbreaks(int) ce O direction double buyingDate Scanner G Bicycle & gears Vehicle) int 0b Vehicle(string, string, int, int, String, int) a productionDate Calendar Oa productionDate setAllFields() turnLeft(int) turnRight(int) stop) getName OBicycle Bicycle(String, String, int, int, String, int, int) setAllFields() turnRight(int Car() Car(String, String, int, int, String, int, int) setAlIFields0 vold vold turnRight(int) 0b turnLeft(int) turnLeft(int) accelerate(int) breaks(int) getPower() void vold accelerate(int) breaks(int) getGears) getProductionDate) setGears(int) setProductionDate(Calendar) OgetPrice) int int String getModel0) Int int Ob getSerialNr() Calendar b getProductionDate() Calendar getDirection) getSpeed) getBuyingDate(0 setName(String) setColour(String) setPrice(int) setPower(int) setProductionDate(Calendar) clone() toString double void mclone() Object irI vold void void toString) msetModel(int) setSerlalNr(String) setDirection(int) vold OsetSpeed(double) setBuyingDate(Calendar) compareTo(Vehicle) clone0 tostring() void void int Object Powered by yFiles

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

Transactions On Large Scale Data And Knowledge Centered Systems X Special Issue On Database And Expert Systems Applications Lncs 8220

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Stephen W. Liddle ,Klaus-Dieter Schewe ,Xiaofang Zhou

2013th Edition

3642412203, 978-3642412202

More Books

Students also viewed these Databases questions

Question

How many multiples of 4 are there between 10 and 250?

Answered: 1 week ago