Maurice Tutor

(5)

$15/per page/Negotiable

About Maurice Tutor

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Algebra,Applied Sciences See all
Algebra,Applied Sciences,Biology,Calculus,Chemistry,Economics,English,Essay writing,Geography,Geology,Health & Medical,Physics,Science Hide all
Teaching Since: May 2017
Last Sign in: 399 Weeks Ago, 1 Day Ago
Questions Answered: 66690
Tutorials Posted: 66688

Education

  • MCS,PHD
    Argosy University/ Phoniex University/
    Nov-2005 - Oct-2011

Experience

  • Professor
    Phoniex University
    Oct-2001 - Nov-2016

Category > Computer Science Posted 28 Aug 2017 My Price 9.00

stoplight to control traffic

1) Suppose you were given the job to write a Java class to run a stoplight to control traffic at an intersection. The state of the stoplight is the color of the light currently being shown (red, green or yellow) and the behavior of the stoplight is that the light is displayed for people to see and that the light changes color under certain conditions. Given the following public interface, write the Java code that goes with each method. Which of these methods are accessors and which are mutators?

public class StopLight { private int currentColor; // color is stored as an integer, 0 for green, 1 for yellow, 2 for red public Stoplight() { // Fill in the constructor. New stoplights should show red by default } public String getColor() { // Fill in the method. It should return the String "RED", "YELLOW", or "GREEN" as appropriate } public void changeColor() { // Fill in the method. If the light is currently red, it should change to green. If the light // is currently green it should change to yellow. And if the light is currently yellow it should // change to red. } }

2) Write a short test program that tests the StopLight class you implemented above. Your short program should create a new StopLight and then cycle through a number of light changes, checking the result after each change.

Answers

(5)
Status NEW Posted 28 Aug 2017 11:08 AM My Price 9.00

Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll

Not Rated(0)