Write a java program for a toy car application

Assignment Help JAVA Programming
Reference no: EM131571017

Help with java problem

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

Reference no: EM131571017

Questions Cloud

Prepare a background paper on the results of your research : You have been asked by the president of the organization to prepare a background paper on the results of your research and to make recommendations.
Case study on impetus of the dhs : Prior to the 9/11 attacks, there were a number of other "terrorist" events that occurred on both U.S. soil and abroad. Read the article discussing the Oklahoma
How you mean this statement : HOW you mean this statement, some reasons WHY you think the way you do, WHY you (dis)agree, HOW such relations could be otherwise.
Prepare a detailed multi-step income statement : The purpose of this assignment is to help you become familiar with the parts of the multiple-step income statement. Prepare detailed multi-step income statement
Write a java program for a toy car application : 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
What is the given recursive method doing : What is the given recursive method doing? Please use a for-loop to implement the same task. public int mystery(int num)
What is the java method doing : What is the following method doing? Please clearly describe it.
Describe what the digital divide : Describe what "the digital divide" is and how serious of an impact the problem has on the quality of life.
Research the martha stewart scandal : Research the Martha Stewart scandal. Describe how the case was handled including her charges and sentencing. Was the sentencing fair

Reviews

Write a Review

JAVA Programming Questions & Answers

  Learn how expressions can be evaluated at run-time

Write a Java program (a collection of Java classes) including a class named ExpressionCalculator that contains a static main method. This main method will prompt the user to enter a constant expression.

  Design and implement in java a bookshop management

System Development for Business Processes - CE00351-5 - design and implement in Java a Bookshop Management System corresponding to the attached scenario. You are not required to implement the entire scenario.

  Discuss what kind of tactics you should use to achieve that

Draw a sequence diagram for this system. Suppose that we want greater availability of the server, discuss what kind of tactics you should use to achieve that.

  Implement a fish-lake simulation

Implement a Fish/Lake simulation similar to the previous assignment. You will then make adjustments to accommodate class hierarchies and make use of inheritance as well as a JAVA interface.

  Create a 2d array of randomly generated ints

Write a complete Java class that will create a 2D array of randomly generated ints that of size 5 rows and 10 columns. Print the values of each cell to a 5x10 table.

  Vector equation of the intersection

Find the vector equation of the intersection of the surface F(x,y)= x+(pi/2)y^2+tan(xy) and the plane x=(pi/3) . let y=t.

  Invoice project - test the invoice application

Test the Invoice Application with an invalid total like $1000 and include the dollar sign. This should cause the application to crash with a runtime error and to display an error message in the Output window. Take a screenshot of the error message..

  Design and develop mobile web application

HC2051 Mobile Web Applications Development. In this group assignment (maximum 5 students) requirement, you are required to design and develop mobile web application using any or all of the techniques you have learned in the class for example: HTML,..

  Develop an app which allows users to keep records

ICT311 - Mobile App Development - report explaining the design of the app. Submit your code via GitHub or BitBucket, and your report to Blackboard Task 2. Please follow the submission instructions on Blackboard.

  What does each part of sharedpreferences data pair represent

What does each part of the SharedPreferences data pair represent? Explain each part of the pair. Name five ways to store data in an app. Why should an app not store massive amounts of data using internal storage?

  Implement avl trees that allows both iterative traversal

implement avl trees that allows both iterative traversal and recursive traversal.iterative traversal is fairly easy if

  Major design flaws and features of the airline

Use the Internet to locate airport kiosk page of one (1) major airline (such as United's Airport Kiosk page). Describe the key factors that constitute a user friendly check-in experience. Examine the major design flaws and features of the airline ..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd