|
Learning objectives:After completing this project, you should be able to:
Items in red are learning objectives for this part of the project. |
Group work
| DefiningYourOwnClasses report
| Time limit
|
DefiningYourOwnClasses
. DefiningYourOwnClassesReport.txt
, placing it in the docs
subfolder of your DefiningYourOwnClasses
project. DefiningYourOwnClassesReport.txt
file. You will use it to record your answers to the questions in all of the parts of this exercise. Start the report with an appropriate title, your names, the date, and a heading to indicate the beginning of Part 1.DefiningYourOwnClasses
project, calling the module DefiningYourOwnClasses
, spelled just like that. DefiningYourOwnClasses
project to your new CVS module. JOptionPane
for all required input and output (I/O) in this project (you are free to use whatever method you prefer for other I/O)..main
method. When it is finished, the program will prompt the user for two complex numbers and display the results of various operations on those numbers. main
method so that it declares and creates a Complex
object. Complex
class.
void setReal(double theReal)
, void setImaginary(double theImaginary)
, double getReal()
, and double getImaginary()
. They should all be public
. double real
and double imaginary
. Both should have initial values of 0.0
and be private
.main
method to test your class. double getMagnitude
and double getArgument
that return the values suggested by their names. Do not add any new fields to your class. getMagnitude
and getArgument
methods are working. void setMagnitude( double theMagnitude )
and void setArgument( double theArgument )
that change the real and imaginary components of the Complex object so that the indicated property is set, but the other property is not changed. x.setMagnitude( someValue )
and then immediately execute x.getMagnitude()
, you could get back something slightly different from someValue
. Find such a value and explain why this happens. void add( Complex addend )
and void subtract( Complex subtrahend )
that change the real and imaginary components in the way suggested by their names.x = x.add( y )
, where x
and y
are Complex
objects. What would the return type of the add
method have to be? void multiply( Complex multiplicand )
and void divide( Complex divisor )
that change the real and imaginary components in the way suggested by their names. DefiningYourOwnClasses1
.