Question
URGENT, PLEASE, I NEED YOUR HELP, I have a java lab, Im trying everything to get it to work, my code is pretty much useless.
URGENT, PLEASE, I NEED YOUR HELP, I have a java lab, Im trying everything to get it to work, my code is pretty much useless. We are supposed to do series and parallel methods, and have it inherit from the class Circuit. I saw a 2 of the same example posted but, they had an issue. I need the main method to be in a different class, as a tester, thats very important.
-------------------------------------------
All of your method/class names need to match what is shown in this document. This is the public interface of your class. The classes and methods you need to implement are as follows:
Circuit single method getResistance. Note that this is simply an empty circuit with no resistors, and therefore the resistance is always 0 for objects of this class. This is the parent class.
Resistor subclass of Circuit. Represents a single resistor. Needs to override the getResistance method from the superclass Circuit. To compute the value of the Resistor object you simply return the resistance value.
Serial subclass of Circuit. Contains an ArrayList
Parallel subclass of Circuit. Contains an ArrayList
------------------------------------------
The teacher also uploaded a demo to demonstrate how the code should function.
/**
* A class to run tests on the Circuit class and subclasses
* @author Horstman
* @version 02/06/2014
*
*/
public class CircuitDemo
{ /**
method that implements tests for Circuit class and sublclasses
@param args - Not Used.
*/
public static void main(String[] args)
{
Parallel circuit1 = new Parallel();
circuit1.add(new Resistor(100));
Serial circuit2 = new Serial();
circuit2.add(new Resistor(100));
circuit2.add(new Resistor(200));
circuit1.add(circuit2);
System.out.println("Combined resistance: " + circuit1.getResistance());
System.out.println("Expected: 75.0");
}
}
-----------------------------------------
Here is the tester class
public class CircuitTester01 {
public static void main(String[] args) {
Serial c1 = new Serial();
c1.add(new Resistor(100));
c1.add(new Resistor(200));
c1.add(new Resistor(150));
System.out.println("c1 total R = " + c1.getResistance());
Parallel c2 = new Parallel();
c2.add(new Resistor(100));
c2.add(new Resistor(100));
c2.add(new Resistor(100));
System.out.println("c2 total R = " + c2.getResistance());
Serial c3 = new Serial();
c3.add(c1);
c3.add(c2);
System.out.println("c3 total R = " + c3.getResistance());
Parallel c4 = new Parallel();
c4.add(c1);
c4.add(c2);
System.out.println("c4 total R = " + c4.getResistance());
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started