and gate- or gate-logical-program , Programming Languages

Assignment Help:

System.in and System.out should not be used anywhere in the programs except in main and only for testing purposes.  All calculations should be done in a method. 

Note:  To use JUnit, you will need to use Eclipse.  There are videos and slides in the Lectures area to help you learn about Eclipse if you are not using it now.

In this lab, you will be constructing a small part of a program that will simulate the workings of an electronic circuit.  Specifically, you will be implementing a few logic gates that, based on the inputs to the gates, produce a true or false value.  The gates should be created with the following guidelines:

AND Gate

Implements the logical AND function (same as the one in the Boolean expressions)

Has a name

Has an output value (which is initially false)

Has a method that takes two Boolean values and, using them, updates the output value

OR Gate

Implements the logical OR function (same as the one in the Boolean expressions)

Has a name

Has an output value (which is initially false)

Has a method that takes two Boolean values and, using them, updates the output value

3 Input AND Gate

Implements the logical AND function (same as the one in the Boolean expressions)

Has a name

Has an output value (which is initially false)

Has a method that takes two Boolean values and, using them, updates the output value

Has a method that takes three Boolean values and, using them, updates the output value

Debug OR Gate

Implements the logical OR function (same as the one in the Boolean expressions)

Has a name

Has an output value (which is initially false)

Has a method that takes two Boolean values and, using them, updates the output value.  This method should store the values of the parameters and modify the name of the class to include the values of the parameters and the value they produced

This should follow (exactly) the format ||=

Where is a single space and the other values in < > are the values of variables stored in the class. (No < > are in the output.)

e.g.  Or Gate 12 false || true = true

As you looked through that list of requirements, you should have noticed that several of the same elements are showing up again and again.  So, the first thing to be done in the lab is to create a base class LogicGate.   This class will contain a name (String), and a calculated (boolean) value and have methods for accessing those values.  Make sure those classes have the appropriate encapsulation.  The getters should be called getValue and getName and should not take any parameters.  LogicGate should also have a constructor that takes a String (for the name) and that initially sets the output value to false.  The final method in LogicGate should be called performLogic and should take two boolean parameters and return nothing.  Because it is not clear what performLogic should do is this this class, make the method and the class abstract.

Starting this way, makes creating the other classes much easier.  Use inheritance to create a class AndGate and a class OrGate.  If you created these classes and LogicGate correctly, you should only have to implement a constructor and the performLogic method for these classes.  The constructor should only take a String parameter.  (HINT: use super to call LogicGate's constructor.)

The next class to create is And3Gate.  This should also use inheritance.  (Which class should it inherit from?  Picking the wrong one will require you to do more work.)  In this class, create a constructor as with the other classes.  However, this class should append " 3 Input" (watch the spaces) to the name of the gate (i.e. the String passed into the constructor).  (HINT:  super must be the first line of the constructor.  You can, however, manipulate what is passed to super.)  In addition, it should have a method called performLogic that takes three boolean parameters and returns nothing.  This method should calculate the result of the three parameters ANDed together and store the result in the classes output value.

The final class to create is DebugOrGate.  (Which class should this inherit from?)  As before, this should create a constructor that accepts a String.  It will also need to override two existing methods performLogic and getName.  performLogic should do exactly what OrGate's method does except it should record the values of the parameters. (HINT: Use super.) (HINT: Use to instance variables in this class to store the parameter values.)  getName should return a modified version of the name of the class.  DO NOT update the actual name!  Just return the name with additional information attached to it.  The format for the information should be (exactly) ||=

(HINT: if you want to call the parent's getName method, make sure you use super.)

Create JUnit tests for all of your classes except LogicGate.  You only need to test methods implemented in the class.  That is, for And3Gate, you only need to check the constructor (i.e. that getName and getValue return the correct values after creating an object) and the 3 parameter performLogic method.  You do not need to test the methods implemented in the parent's class. 


Related Discussions:- and gate- or gate-logical-program

Super ascii string cost in c++, Ask question #Minimum 100 A string S is sai...

Ask question #Minimum 100 A string S is said to be "Super ASCII", if it contains the character frequency equal to their ascii values. String will contain only lower case alphabets

Algorithm of sort the given array remove the repeated value, Short Arrays: ...

Short Arrays: Array = randi(10,1,randi(6,1,1)+4)-5 This command will generate an array which you should be able to evaluate by hand (and also have your code evaluate for te

Write the html code to bind this xml data, Question: (a) (i) Describe w...

Question: (a) (i) Describe what an XML Data Island is and outline the restrictions of using a Data Island. (ii) The following XML file book.xml is used to keep track of a l

Components of dot net framework 3-5, Components of .NET Framework 3.5 .NET ...

Components of .NET Framework 3.5 .NET Framework Conceptual Overview Presents the .NET Structure and its elements. Installing the .NET Framework Provides information about .NET Stru

Amen, Write a program that inputs two positive integers of, at most, 20 dig...

Write a program that inputs two positive integers of, at most, 20 digits and outputs the sum of the numbers. If the sum of the numbers has more than 20 digits, output the sum with

Access modifiers, Access Modifiers Convenience Modifiers or we can say (Acc...

Access Modifiers Convenience Modifiers or we can say (Access Specifies) identifies as the opportunity of accessibility of an Item and its associates. All C# kinds and kind associat

Write a program to draw the truck , Write a program to draw the truck follo...

Write a program to draw the truck following figure. The program should buttons to provide When the truck runs left wheels must rotate in the correct direction. Rotating whe

Program for average grades for 10 students, Assume that you are a college p...

Assume that you are a college professor needing to average grades for 10 students. Write a program that asks for each student's name and grade. Print the list on-screen with each s

Simulation algorithm, Please remember to read and follow all of the assignm...

Please remember to read and follow all of the assignment guidelines. This assignment will expand upon the simulation algorithm given in class to produce a program which may be u

Write Your Message!

Captcha
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