Hi everyone,
Apparently I'm very bad at this whole programming thing, but, nevertheless, I am currently in a CPS course and in dire need of assistance!
I have 3 objects set up: TwoNumbers, TwoNumbersTester, and Test. When I build the code, it's all fine. When I run the code, though, I get the error shown in the title of this forum post.
Here is my code for TwoNumbers.java:
public class TwoNumbers extends Object // Class header
{
private double number1; // Instance variables
private double number2;
public TwoNumbers( double n1 , double n2 ) // Constructor method
{
number1 = n1;
number2 = n2;
}
public void setNums( double n1 , double n2 ) // Accessor method
{
number1 = n1;
number2 = n2;
}
public double getSum() // Accessor method
{
return number1 + number2;
}
}
My code for TwoNumbersTester.java:
public class TwoNumbersTester
{
public TwoNumbersTester()
{
}
public void startTest()
{
TwoNumbers equation1;
TwoNumbers equation2;
equation1 = new TwoNumbers( 10 , 15 ); // Set numbers for equation
equation2 = new TwoNumbers( 100 , 200 );
//*** Test first instance of TwoNumbers object ***//
System.out.println( equation1.getSum() ); // Display sum
//*** Test second instance of TwoNumbers object ***//
System.out.println( equation2.getSum() ); // Display sum
}
}
And, my code for Test.java:
public class Test
{
public static void main ( double args [] )
{
TwoNumbersTester test = new TwoNumbersTester();
test.startTest();
}
}
This is about the trillionth error I've attempted to solve in this program, and it's the last one I'm stuck on. Can anyone help me out? Where is my error? Or, is it not in this code and maybe in one of the other objects?
Thanks so much, in advance, for your help!