Hi, I you probably have much annoyance with homework help, but I'm a first year student in high school doing a AP comp sci class.
I'm currently working on my eighth program, the past 7 were all solved by me, and I helped others with it, so I'm not trying to leech a quick answer, just grab some help.
Anywho,
My assignment is
Create a class called Complex for performing arithmetic operations with complex numbers. Complex numbers have the form
realPart + imaginaryPart * i, where i = square root of -1
Write a program to test your class. Use double variables to represent the private data of the class. Provide a constructor that enables an object of this class to be initialize when it is declared. Provide a no-argument constructor with default values in case no initializers are provided. Provide public methods that perform the following operations:
a) Add two Complex numbers: The real parts are added together and the imaginary parts are added together.
b) Subtract two Complex numbers: The real part of the right operand is subtracted from the real part of the left operand, and the imaginary part of the right operand is subtracted from the imaginary art of the left operand.
c) Print Complex numbers in the form a + bi, where a is the real part and b is the imaginary part.
I really don't understand private methods, constructors, and calling different classes.
I have had experience with using methods, control loops, and all the basics up to arrays, but this topic has gotten me puzzled. I've looked through my huge thousand page java book with no help.
Normally I'd ask a friend or the teacher to work with, but in this case, We have a 2 week break, and it's due when we get back, so that's not a choice.
We were also provided a driver file
/*
Purpose: The purpose of this class is to test the Complex class. */
public class ComputeComplex {
public static void main (String[] args) {
Complex num1 = new Complex( 3, 2 );
Complex num2 = new Complex( 4, 9 );
Complex num3 = new Complex();
Complex num4 = new Complex( -5, 7);
Complex num5;
num5 = num1.subtract( num2 );
System.out.println( num5 );
System.out.println ( num2.subtract( new Complex(4, -2) ));
System.out.println ( num1.subtract( num1 ) );
System.out.println ( num2.add( num4 ) );
System.out.println ( "num3 = " + num3 );
System.out.println ( num1.subtract( num2 ).add(num4) );
System.exit( 0 );
}//main
}//ComputeComplex
Any help or discussion appreciated. We can talk about this over AIM or email if you can help me.
Thanks and merry Christmas!