[Solved] Write a java program for a Toy Car Application

30 $

File Name: Write_a_java_program_for_a_Toy_Car_Application.zip
File Size: 433.32 KB

SKU: [Solved] Write a java program for a Toy Car Application Category: Tag:

Or Upload Your Assignment Here:


Write a java program for a Toy Car Application. This Car Control can be used to command a electric toy car to power on, power off, go fast, slow down, turn left and turn right. Create an interface “Controllable” which specifies the following abstract methods: void powerOn(); void powerOff(); void turnRight(); void turnLeft(); void goFaster(); void slowDown(); Define an ElectricCar class that implements the following methods: void powerOn () This method sets a flag to indicate the car is powered on void powerOff () This method sets a flag to indicate the car is powered off. void turnRight() Turns the car by 5 degrees to the right. void turnLeft() Turns the car by 5 degrees to the left void goFaster () Commands the car to move forward and increase the car speed by 2 mph. void slowDown () Commands the car to reduce the speed by 2 mph. String toString() Override this method to output the car information. Use the following main method to test your program: public class ElectricCarApp { public static void main(String[] args) { Controllable toy = new ElectricCar(); toy.powerOn(); toy.goFaster(); toy.turnLeft(); System.out.println(toy); toy.turnLeft(); System.out.println(toy); toy.slowDown(); System.out.println(toy); toy.powerOff(); toy.turnRight(); System.out.println(toy); } } Expected Output: car travels in 355 deg at the speed of 2 mph car travels in 350 deg at the speed of 2 mph car is stopped car is powered off

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] Write a java program for a Toy Car Application
30 $