Question

In: Computer Science

I need this in PSEUDO CODE: This looks long, but only because I have to give...

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

Solutions

Expert Solution

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()

Related Solutions

Develop an algorithm for INSERTION SORT. Give the pseudo-code version. Convert your pseudo-code into a Java...
Develop an algorithm for INSERTION SORT. Give the pseudo-code version. Convert your pseudo-code into a Java program.
I know this is a long problem but I couldn't break it up because you need...
I know this is a long problem but I couldn't break it up because you need all the information. But it is only counted as one question on my homework. Fuming because you are stuck in traffic? Roadway congestion is a costly item, both in time wasted and fuel wasted. Let x represent the average annual hours per person spent in traffic delays and let y represent the average annual gallons of fuel wasted per person in traffic delays. A...
hi i need a code that will give me this output, For the multiply_list, the user...
hi i need a code that will give me this output, For the multiply_list, the user will be asked to input the length of the list, then to input each element of the list. For the repeat_tuple, the user is only asked to enter the repetition factor, but not the tuple. Your program should take the list created before and convert it to a tuple. output expected: (**user input**) ******Create your List ****** Enter length of your list: 3 ******...
Give the algorithms in pseudo code of the enqueue and dequeue procedures. Constraint: the structure implementing...
Give the algorithms in pseudo code of the enqueue and dequeue procedures. Constraint: the structure implementing the queue must only be pointed to by a single field (example: head, tail or number of elements, etc.)
I need a working MATLAB CODE for the Gram Schimdt process Please give the code fast...
I need a working MATLAB CODE for the Gram Schimdt process Please give the code fast Its urgent The code must run on any matrix given It should be a generic code Dont answer any wrong code or else i will badly dislike
Write pseudo code for Min_Heap_Delete(A,i) which deletes the item at position i in Min_Heap A. Assume...
Write pseudo code for Min_Heap_Delete(A,i) which deletes the item at position i in Min_Heap A. Assume that A is a one-dimensional array. Hint:Think about “bubbling up” and “bubbling down” and the operations that do these, then give the best upper bound you can on the worst case running time of your method, in ordered notations.
Write PSEUDO CODE! for Min_Heap_Delete(A,i) which deletes the item at position i in Min_Heap A. Assume...
Write PSEUDO CODE! for Min_Heap_Delete(A,i) which deletes the item at position i in Min_Heap A. Assume that A is a one-dimensional array. Hint:Think about “bubbling up” and “bubbling down” and the operations that do these, then give the best upper bound you can on the worst case running time of your method, in ordered notations.
I need to understand how I would edit this code without changing anything, only adding. I...
I need to understand how I would edit this code without changing anything, only adding. I am not looking for the exact answer, just information on how I would use the given code to complete some of the todo statements. Thank you! // include this header file so we can use `printf()` #include <stdio.h> // every C program must implement the `main()` function int main(int argc, char *argv[]) {    //TODO: check for enough arguments       // save the...
Java homework problem: I need the code to be able to have a message if I...
Java homework problem: I need the code to be able to have a message if I type in a letter instead of a number. For example, " Please input only numbers". Then, I should be able to go back and type a number. import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; public class LoginGui {    static JFrame frame = new JFrame("JFrame Example");    public static void main(String s[]) {        JPanel panel...
I need to add this checkpoint to an existing code that i have in python Checkpoint...
I need to add this checkpoint to an existing code that i have in python Checkpoint 1: Once you have created and tested the Bank Account Class create subclasses to the BankAccount class. There should be two subclasses, CheckingAccount and SavingsAccount. You should add interest_rate to the parent BankAccount class. To the CheckingAccount add variables called per_check_fee default to false and allow_overdraft default to True. To SavingsAccount add the variable transactions_per_month, default it to 5. Create instances of CheckingAccount and...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT