Results 1 to 4 of 4
  1. #1
    sev51 is offline Member
    Join Date
    Jan 2009
    Posts
    7
    Rep Power
    0

    Unhappy Java + OOP + Logic Gates = HELP!

    If you were asked to write a program that would be able to draw a network of gates on the screen and determine the output of that network, you should design several classes. Design these classes. Draw a diagram to show how the classes are related. Include a detailed description of ALL encapsulated data and ALL methods you would need. (No actual steps are required for your methods)

    okay so at first this task seemed easy... I decided that there should be an abstract Gate class, that has 2 instance variables (int input1,int input2) and the method would be calcOutput which determines an output based on the inputs. Then AND, OR, NOT, NAND, etc would all be subclasses of this class inheriting these variables and the method, but it seems a far too simple solution and i must be overlooking some cases..:confused:

  2. #2
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Posts
    671
    Rep Power
    6

    Default

    For logic, I'd use boolean rather than ints. But you need something that defines and stores the network, you need something that draws the individual components and connects them, and lays them out nicely. Connections are probably a class, the layout manager is probably a class.

  3. #3
    sev51 is offline Member
    Join Date
    Jan 2009
    Posts
    7
    Rep Power
    0

    Default

    But couldn't I just make separate draw methods in each of the logic gate classes, and also have them inherit a getOutput method from the abstract Gate class?

  4. #4
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Posts
    671
    Rep Power
    6

    Default

    Sure, but you still need something that defines how they are connected together, and something that lays the components out so they don't all draw on top of eachother.

Similar Threads

  1. [SOLVED] need help with logic operator
    By auralius in forum New To Java
    Replies: 10
    Last Post: 12-25-2008, 10:01 PM
  2. Separating program logic and GUI
    By loopingman in forum AWT / Swing
    Replies: 0
    Last Post: 12-08-2008, 02:46 PM
  3. Logic to generate a pattern
    By vijay_2008 in forum Advanced Java
    Replies: 3
    Last Post: 11-23-2008, 02:40 AM
  4. Cant get the logic right
    By jermaindefoe in forum New To Java
    Replies: 4
    Last Post: 03-11-2008, 12:22 AM
  5. iterate HashMap with logic
    By Heather in forum Web Frameworks
    Replies: 2
    Last Post: 07-03-2007, 09:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •