CS21 Week4 In-Class Exercises for Thursday
If you have not alread done so, create a week4 subdirectory in
your cs21 subdirectory, and from your
week4 subdirectory, copy over my week4 files:
% cd
% cd cs21
% mkdir week4
% cd week4
% pwd
% cp ~newhall/public/cs21/week4/* .
% ls
Makefile QuadDriver.java Quadralateral.java Student.java StudentDriver.java
- Open the Quadralateral.java file. Implement the the Area method,
and add code to the QuadDriver class to test it out.
Before writing code, answer these questions to help you figure out
what you need to do:
- does this method take any input value? if so, how many and what
are their types?
- does this method return a value? if so, what is its type?
- think about the implementation:
what data member(s) will you use or modify?
do you need a loop? a nested loop? conditional stmts?
arithmetic operations? ...
- Next, implement the equalArea method of the Quadralateral class,
and add code to the QuadDriver class to test it out.
- Next implement the equals method of the Quadralateral class, and
add code to the QuadDriver class to test it out.