CS 2102 - D-term 14

Homework 1 - Designing with Interfaces in Java

Due: Friday, March 21 at the beginning of class (12pm)


This assignment is to be done individually. The assignment is due at the beginning of class (12pm) on Friday, March 21. We'll be going over a solution to the assignment in class on Friday, so late assignments will not be accepted. NO EXCEPTIONS.

Assignment Goals


Problem Statement

Many tournaments are organized into elimination rounds, in which pairs of remaining contestants play a match and the winner advances onto the next round. In this assignment, we will design a class hierarchy that models tournaments for various kinds of games.

The following Racket data definitions model the elimination rounds of a sports tournament (where the sport can be either soccer or baseball):

;; Tournament is either
;; - (make-init-match MatchData)
;; - (make-advance-match MatchData Tournament Tournament)
(define-struct init-match (data))
(define-struct advance-match (data feeder1 feeder2))
 
;; MatchData is (make-match-data String String Score)
(define-struct match-data (contestant1 contestant2 score))
 

;; Score is either
;; - (make-soccer-score Number Number Boolean)
;; - (make-baseball-score Number Number Number)
(define-struct soccer-score (goals1 goals2 extra-time?))
(define-struct baseball-score (runs1 runs2 total-innings))
Using the given Racket data definitions as a starting point, design a class hierarchy for a Java program that models a tournament. Your hierarchy should be represented using a class diagram as described in the "Migrating to Java" notes. Each box in the class diagram will specify fields only (the part of the box reserved for methods will be empty). Nested classes (see Lab 1) should be represented in the diagram with a solid arrow from the field to the box representing the type of the field. For example, in Lab 1 the Song class defined a field onAlbum of type Album

Grading

You will be graded on

What to Turn In

Your solution should be submitted on paper (either handwritten or computer generated). If your assignment is handwritten, make sure it's legible; illegible work will not be graded. The first page of your solution should contain only your name, WPI username, and section number (the reverse side of the first page should be blank). The following page(s) should contain your class hierarchy. All pages must be stapled together. We're asking you to follow these rules so that we can get your assignments graded and returned to you as quickly as possible.