SDSU CS 535 Object-Oriented Programming & Design
Fall Semester, 2001
Assignment 2
    Assignment Index        
© 2001, All Rights Reserved, SDSU & Roger Whitney
San Diego State University -- This page last updated 20-Sep-01

Assignment 2

Due Thursday September 27.

1. Find the class Circle. What is its parent class? What namespace is the Circle class in. What category is the Circle class in?

2. Find all references to the Circle class. List the classes and methods were the Circle class in referenced.

3 Find all senders of the method "canBeFilled". List the classes and methods where "canBeFilled" is referenced.

4. List all classes that implement the method "canBeFilled".

5. Add a method asLetterGrade to the Integer class. This method is to return a character representing the letter grade corresponding to the numerical score using the following table.

Score
Letter grade
90 or higher
A
80-89
B
70-79
C
60-69
D
59 or less
F

So 88 asLetterGrade would return B. 152 asLetterGrade would return A. 12 asLetterGrade would return F. -123 asLetterGrade would return F.

6. In a workspace complete the following code so it will print the remainder of a/ b.

| a b |
a := (Dialog request: 'Type an integer for a') asNumber asInteger.
b := (Dialog request: 'Type an integer for b') asNumber asInteger.
"Add code here to print the remainder of a divided by b in the Transcript"

7. Add the method divides: to the integer class.

divides: anInteger
   "returns true if the receiver evenly divides anInteger"

So 2 divides: 4 returns true while 4 divides: 7 returns false.

8. Add the method isPrime to the integer class.

isPrime
   "Returns true if the receiver is a prime number"

So 3 isPrime returns true while 6 isPrime returns false. Don't worry about writting efficient code.

Copyright ©, All rights reserved.
2000 SDSU & Roger Whitney, 5500 Campanile Drive, San Diego, CA 92182-7700 USA.
OpenContent license defines the copyright on this document.

    visitors since 20-Sep-01