In: Computer Science
I need this in PSEUDO CODE:
This looks long, but only because I have to give you my answer to the first part.
First part of the questions (already answered)
GDOT has contacted you to help write code to control the cross walk signals in Georgia. You must create a Crosswalk Signal class with three hidden attributes (Walk, Hurry and Wait), two constructors (a default that sets all lights to on and an overloaded that sets Hurry to on for testing purposes) and a method that changes the active light to the next in the sequence (Walk, – Hurry – Wait).
CLASS NAME & VARIABLES
CLASS GDOT
// Instance Variable
Bool, Green, Yellow, Red
DEFAULT CONSTRUCTOR
GDOT()
GREEN = TRUE
YELLOW = TRUE
RED = TRUE
OVERLOADED CONSTRUCTOR
GDOT(BOOL G, BOOL Y, BOOL R)
GREEN =
G
YELLOW = Y
RED =
R
CLASS METHOD
VOID CHANGE_LIGHT()
IF GREEN
GREEN =
FALSE
YELLOW =
TRUE
ELSE IF YELLOW
YELLOW =
FALSE
RED = TRUE
ELSE IF RED
RED =
FALSE
GREEN =
TRUE
ELSE
GREEN = TRUE
Here is the part I need help with:
Now you must create two Crosswalk Signal objects (using pseudocode) from the class you just created to prove that your class works properly for GDOT, the first object should use the default constructor and the second object should use the overloaded constructor. Using the objects you just created, call the method to change the light to the next in the sequence
For the second part, we have to create two objects of type GDOT (according to the name of the class). The first object is created using default constructor and the second one is using overloaded one and the objects can be created in the driver function that is the main function.
MAIN ( ) // the driver function
GDOT object1, object2(TRUE, FALSE, FALSE)
/* The first object that is object1, is created using the default constructor and the value of GREEN, YELLOW and RED are TRUE as defined in the default constructor. The second object that is object2 is called using the overloaded or parameterized constructor. The parameters passed here are TRUE, FALSE and FALSE (the user can pass any parameters) and according to the constructor GREEN is TRUE, YELLOW is FALSE and RED is FALSE. */
object1.CHANGE_LIGHT()
/* The class method is called by the first object here and the value of GREEN and YELLOW are changed. */
object2.CHANGE_LIGHT()
/* The class method is called by the second object and the values of GREEN and YELLOW are changed according to the method. */
The statements in bold and italics are the part of pseudo code and the statements written after them are the comments describing them.
The pseudo code looks like :-
MAIN ( )
GDOT object1, object2(TRUE, FALSE, FALSE)
object1.CHANGE_LIGHT()
object2.CHANGE_LIGHT()