ComplexNumbs - public int getRealNum return Re public int...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
package myPeach; /** */ public class ComplexNumbers { /** A and B are the real parts while Ci and Di are the imaginary ones. */ private int Re; private int Im; /* *================================= *Constructors *================================= */ public ComplexNumbers(ComplexNumbers po) { this(po.getRealNum(), po.getImagNum()); } public ComplexNumbers(int real) { this (real,0); } public ComplexNumbers(int ima, double b){ this (0,ima); } public ComplexNumbers(int ima, int real) { setRealNum(real); setImagNum(ima); } /*============================ *Methods *============================ */ //set and get methods
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: public int getRealNum(){ return Re; } public int getImagNum(){ return Im; } public void setRealNum(int REAL) { Re = REAL; } public void setImagNum(int IMAG){ Im = IMAG; } //Add method public ComplexNumbers add(ComplexNumbers po) { int a, b, c, d; ComplexNumbers sum; a = this.getRealNum(); b = this.getImagNum(); c = po.getRealNum(); d = po.getImagNum(); sum = new ComplexNumbers(a+c, b+d); return sum; } public ComplexNumbers add(int real) { ComplexNumbers po = new ComplexNumbers(real, 0); Fraction sum = add(frac); return sum; } //Subtract Method }...
View Full Document

{[ snackBarMessage ]}

Page1 / 2

ComplexNumbs - public int getRealNum return Re public int...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online