Practice Problems
Problem 1
Problem 2

Assignment 3

Goals: Learn how to follow the design recipe for designing methods in Java.

As the part of the design recipe, learn how to design tests for the methods and how to run them.


The names of the projects and some of the project files must be exactly the same as specified in the assignment. Failure to do so makes it impossible for the graders to run your submission and results in immediate loss of at least 50% of the homework credit.

Make sure you follow the style guidelines for code indentation.

You will submit this assignment by the deadline using the Web-CAT submission system.

With each homework you will also submit your log file named pairxxx.txt where you replace xxx with your pair number.

On top of every file you submit you will have the names of both partners, and the pair number.

The .txt file will be the log of your work on this assignment. Each log entry will have data and time, who was present (one or both of the partners) and a short comment decribing what you were working on.

Due Date: Tuesday, January 29th, 11:59 pm.

Practice Problems

Work out these problems on your own. Save them in an electronic portfolio, so you can show them to your instructor, review them before the exam, use them as a reference when working on the homework assignments.

Problem 1

The following DrRacket data definition describes the contents of a web site:

;;A Web Page (WP) is (make-wp String String [Listof Item (ILoI)])

(define-struct wp (url title items))


;; An Item is one of

;; -- Text

;; -- Image

;; -- Link


;; A Text is (make=text String)

(define-struct text (contents))


;; An Image is (make-image String int String)

(define-struct image (file-name size file-type))


;; A Link is (make-link String WP)

(define-struct link (name page))

We are giving you the names of the classes or interfaces you will probably need — make sure you use these names to define your interfaces and classes.

For lists of items, the names of the two classes should be MtLoI for the empty list and ConsLoI for the nonempty list, and the name of the interface that represents the list should be ILoI.

Make sure the object that represents the the "My Pets" page is named myPetsWP

Name your Examples class ExamplesWP

Problem 2

Continue the work on the Mobiles from the lab 3.

Make sure the object that represents the shown mobile is named calder, and the name of your methods are isBalanced, buildMobile, maxWidth, and mobileImage.

Name your Examples class ExamplesMobiles