Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Now, consider the problem of const gates in the context of the posted solution t

ID: 3595243 • Letter: N

Question

Now, consider the problem of const gates in the context of the posted solution to HW3. When the power comes on, which is to say, when the simulation starts, all the wires and all of the outputs of all of the gates are at logical false. After delay, the true output of each const gate goes from false to true.

Assume that class ConstGate has a method outputChangeEvent(t) that is used only for the change described above, where the parameter t indicates the time at which the change occurs.

a) Where in the code for class ConstGate should the code go that schedules outputChangeEvent?

Explanation / Answer

class ConstGate extends Gate

{

/** The constructor used only from within class Gate

* @param name used to initialize the final field

* @param delay used to initialize the final field

*/

protected ConstGate( String name, float delay )

{ super( name, delay ); }

/** tell the gate that one of its input pins is in use

* @param pinName

*/

public void registerInput( String pinName )

{ Errors.warn( "Illegal input pin: " + name + " " + pinName ); }

/** tell the gate that one of its output pins is in use

* @param pinName

*/

public void registerOutput( String pinName )

{

if ("true".equals( pinName ))

{

Errors.warn( "Output pin in use: " + name + " " + pinName ); //Just checking the warnings as after delay output of each const gate goes from false to true.

delay++; pinName= "false";

}

else if ("false".equals( pinName ))

{

Errors.warn( "Output pin not in use: " + name + " " + pinName ); delay--; pinName= "true";

}

else

{

Errors.warn( "Illegal output pin: " + name + " " + pinName );

}

}

/** check the sanity of this gate's connections

*/

public void checkSanity()

{

  

if ("true".equals( pinName )) // modification is done to check the gates connections with the input pins

{

Errors.warn( "Input pin in use: " + name + " " + pinName );

}

else

{

Errors.warn( "Illegal input pin: " + name + " " + pinName );

}

}

/** reconstruct the textual description of this gate

* @return the textual description

*/

public String toString()

{

return "gate " + name + " const " + delay;

}

} // class ConstGatession is over, conduct the user training sessions (4 days).

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote