Comp201: Principles of Object-Oriented Programming I
Spring 2006 -- 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 .

  1. (15 pts total) Write a class called MathFuncs that represents a collection of mathematical functions.
    1. (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.
    2. (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.
    3. (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).
  2. (15 pts total) Write a class that represents rectangle, called Rectangle with the following specifications:
    1. (7 pts) Two double fields called _width and _height. (We will use the convention that all field names begin with an underbar.)
    2. (8 pts) A method called getArea that takes no input parameters and returns a double. The area of the rectangle should be returned.
  3. (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

  1. 15 pts total: class declaration and curly braces – 3 pts (spread across sub problems if necessary)
    1. 5 pts total:
      1. Input params correct - 2 pts
      2. Math and return value correct – 2 pts
    2. 5 pts total
      1. Input params correct - 2 pts
      2. Math and return value correct – 2 pts
    3. 5 pts total
      1. Input params correct – 2 pts
      2. Correct delegated call – 2 pts
      3. Correct return value – 1 pt
  2. 15 pts total:: class declaration and curly braces – 3 pts (spread across sub problems if necessary)
    1. 7 pts: total:
      1. has fields – 3 pt
      2. Proper type on fields – 4 pts
    2. 8 pts total:
      1. method exists – 2 pt
      2. Proper return type – 2 pt
      3. No input parameters – 2 pt
      4. Proper math and return value – 2 pts.
  3. 45 pts total. Criteria same as Prob. 2.
     

 


Last Revised Thursday, 03-Jun-2010 09:50:12 CDT

©2006 Stephen Wong and Dung Nguyen