Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Java inheritance program using gates.

$
0
0
I have to create a program using java inheritance while also incorporating the gave gates (and, or, nand, nor). Then i have to take the java gates and test them through the program. So far the program i have encounters errors. Im just looking for help on what i am doing wrong or what else needs to be done.

public abstract class Gates {

    public abstract boolean doOperation(boolean a, boolean B)/>/>;

}

public class AND extends Gates {
    
	public boolean doOperation(boolean a, boolean B)/>/> {
		return a && b;
	}

}

public class OR extends Gates {
    
	public boolean doOperation(boolean a, boolean B)/>/> {
		return a || b;
	}

}

public class NAND extends Gates {
    
	public boolean doOperation(boolean a, boolean B)/>/> {
		return !( a && B)/>/>;
	}

}

public class NOR extends Gates {
    
	public boolean doOperation(boolean a, boolean B)/>/> {
		return !(a || b );
	}

}

public class GatesTest {
	
	public static void main(String args[]) {
	
	Gates gates = new AND();
	System.out.println("gates.doOperation(true,false)");
	}
}



Here is the error i encounter:


Exception in thread "main" java.lang.Error: Unresolved compilation problem: 

	at GatesTest.main(Gates.java:41)



Thank you very much

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>