On this page:
Problem 1
Problem 2
Problem 3
Design
8.6

Assignment 1: Designing complex data

Goals: Practice designing the representation of complex data.

You may submit one .java file containing the solution to all of these problems, or you can submit one .zip file containing an individual .java file for each of these problems.

Problem 1

Design a class Statue to represent the following information about statues:

Everywhere in this assignment that you see italic, fixed-width text, it is intended to be the name of a field, identifier, class name or interface name you must define...but you likely must modify that name a bit to conform to our Java naming conventions: hyphenated-names are written in camelCase, and interface names begin with an uppercase I.

Everywhere that you see fixed-width text, it is exactly the name you must use.

Make at least three examples of instances of this class, in the class ExamplesStatue. Two of the examples should be objects named statueOfLibery and venusDeMilo and should represent the following two statues:

Note: If the year 2019 is represented as 2019, and 1886 as 1886, what number makes sense to use for 115 BC?

Problem 2

Here is a data definition in DrRacket:

;; A Soup is one of:
;; -- Broth
;; -- Ingredient
 
;; A Broth is a (make-broth String)
(define-struct broth [type])
 
;; An Ingredient is a (make-ingredient Soup String)
(define-struct ingredient [more name])
 

Make sure the two sample soups given above are named yummy and noThankYou. The rightmost ingredients given above should be the outermost ingredients in your example.

Problem 3

We’ve been asked to help build a new, totally original, deck-building game, Oh-Gi-Yu. To start, we’re designing representations for the resources a player can have and the actions they can take during their turn. A player can have three kinds of resources: Monster, Fusion, and Trap.

A Monster has a name, such as Bright Magician, hp (short for hit points, measured as an integer), and an attack rating (measured as an integer).

Fusion has a name, such as Green-Eyes Epic Dragon, monster1 and a monster2 of which it is comprised. Note that these can only be Monsters, not other Fusions.

A Trap has some description and a flag continuous denoting whether its effect is instant or occurs over a period of time.

As the game is under construction, the player can only perform two kinds of actions right now: they can Attack one monster with another (be it a fusion or non-fusion monster), or they can Activate a trap card.

An Attack involves an attacker and a defender, both of which are monster resources (as in, not trap cards). To succesfully attack, the attacker’s attack value must be worth more than the defender’s hp. A Fusion’s HP and attack is derived from the sum of its monsters’ HP and attack. Note: You do not have to implement this calculation in code.

Be sure to only define examples Attacks that are succesful.

We’re placing a lot of restrictions on the data, such as attacks only involving monsters, and attackers needing to have more attack points than defenders have HP, but aren’t actually enforcing these in the code. The ways to enforce these constraints will be further explored later in the semester.

An Activate has a trap (which should be a Trap) and a target (a monster, fusion or otherwise) it is targeting.

Name your action examples attack1, attack2, activate1, activate2, etc.

Design

Note that we have described a data definition which groups monsters, fusions, and trap cards all as resources. Keeping in mind the actions described above, was this a good data design? If so, why, and if not, why not? Leave a brief comment below your examples in your examples class with your answer, and if you think it’s a poor design choice, briefly theorize about an alternative design that would make more sense. }