|
Comp201: Principles of Object-Oriented Programming I
Spring 2007 -- HW 01
|
See Schedule Page for due date!
Save all of your work in a directory called HW01 on your U: drive
(Owlnet account) inside a directory called Comp201 .
- (15 pts total) Write a class called MathFuncs
that represents a collection of mathematical functions.
- (5 pts) Write a method called add
that takes two doubles
as input parameters and returns a double.
The returned value should be the sum of the input values.
- (5 pts) Write a method called sqr
that takes one double
as input parameters and returns a double.
The returned value should be the square of the input value.
- (5 pts) Write a method called sumsqr
that takes two doubles
and returns a double.
The return value should be the sum of the squares of the input values.
Do not duplicate the above math! Use the methods that you have already
written. Note: an object can call one of its own methods simply by
using the method's name (i.e. no object name is necessary).
- (15 pts total) Write a class that represents rectangle, called Rectangle
with the following specifications:
- (7 pts) Two
double
fields called _width
and _height. (We will
use the convention that all field names begin with an underbar.)
- (8 pts) A method called
getArea
that takes no input parameters and returns a
double.
The area of the rectangle should be returned.
- (45 pts total) Repeat the previous problem but instead, create classes to
represent a square, a circle, and a triangle. You will need to modify the
number of fields and input parameters and their names.. Use names that
are appropriate for the process being performed! Hint: Math.PI
is a value that represents the number pi.
75 pts total.
When you have completed your homework, zip up the
entire HW01 directory and submit the zipped file using the file upload
link on the Upload Page.
Grading Criteria
- 15 pts total: class declaration and curly braces – 3 pts (spread
across sub problems if necessary)
- 5 pts total:
- Input params correct - 2 pts
- Math and return value correct – 2 pts
- 5 pts total
- Input params correct - 2 pts
- Math and return value correct – 2 pts
- 5 pts total
- Input params correct – 2 pts
- Correct delegated call – 2 pts
- Correct return value – 1 pt
- 15 pts total:: class declaration and curly braces – 3 pts
(spread across sub problems if necessary)
- 7 pts: total:
- has fields – 3 pt
- Proper type on fields – 4 pts
- 8 pts total:
- method exists – 2 pt
- Proper return type – 2 pt
- No input parameters – 2 pt
- Proper math and return value – 2 pts.
- 45 pts total. Criteria same as Prob. 2.
Last Revised
Thursday, 03-Jun-2010 09:50:16 CDT
©2007 Stephen Wong and Dung Nguyen