Instructions
Practice Problems
Problem 1
Problem 2
Version: 5.2.1

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.

Instructions

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. We will be practicing its use during the lab next week.

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: Thursday, September 27th, 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 data, the names of the two classes should be always starting with Mt for the empty lits and Cons for the nonempty lists.

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, isBalbuildMobileanced, and mobileImage.

Name your Examples class ExamplesMobiles