On this page:
1.1 Instructions
Practice Problems
Problem 1: Real Estate Listings
What to submit
Problem 2: Organizing Apps
What to submit
Problem 3: Sims
What to submit
8.5

Assignment 1: Designing complex data

Goals: Practice designing the representation of complex data.

1.1 Instructions

Be very, very careful with naming! The solution files expect your submissions to be named a certain way, so that they can define their own Examples class with which to test your code. Therefore, whenever the assignment specifies:
  • the names of classes,

  • the names and types of the fields within classes,

  • the names, types and order of the arguments to the constructor, or

  • filenames,

...be sure that your submission uses exactly those names. Additionally, make sure you follow the course style guidelines. For now the most important ones are: using spaces instead of tabs, indenting by 2 characters, following the naming conventions (data type names start with a capital letter, interfaces begin with an uppercase I, names of fields and methods start with a lower case letter), and having spaces before curly braces.

You will submit this assignment by the deadlines using the course handin server. Follow A Complete Guide to the Handin Server for information on how to use the handin server. You may submit as many times as you wish. Be aware of the fact that close to the deadline the server may slow down to handle many submissions, so try to finish early. There will be a separate submission for each problem - it makes it easier to grade each problem, and to provide you with the feedback for each problem you work on.

Due Date: Thursday, January 19th, 9:00 pm

Practice Problems

Work out these problems from How to Design Classes 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.

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.

Problem 1: Real Estate Listings

We are designing a data representation for a real estate listing. For each listing we need to collect the following information:

Design the class RealEstateListing that represents the information about a listing.

Make at least three examples of instances of this class, in the class ExamplesListings. Two of the examples should be objects named bostonCondo and beachHouse and should represent the following two listings:

What to submit

You should submit your data definitions and examples in a file named Listing.java

Remember to check the feedback in handins for Style and Checker Tests in handins!

Problem 2: Organizing Apps

A smart phone model allows users to organize their apps in sets related to the apps’ purposes.

Here is a data definition to represent an app set in DrRacket:

;; An AppSet is one of:
;; -- Folder
;; -- Apps
 
;; A Folder is a (make-folder String)
(define-struct folder [title])
 
;; Apps is a (make-apps String AppSet)
(define-struct apps [app-name others])
 

Make sure the two sample sets given above are named travelApps and foodApps.

Note: the descriptions above are listed in the order that you would add the apps to a folder in real life. Think carefully how this should be represented as data.

Name the class that holds the examples of your group data ExamplesSets.

What to submit

You should submit your data definitions and examples in a file named AppSets.java

Remember to check the feedback in handins for Style and Checker Tests in handins!

Problem 3: Sims

We’ve been asked to help build an expansion pack for Sims 5: University Life. We’re trying to figure out the gameplay mechanics, so we’re starting with representations for Sims students, behaviors and places they can visit around the game world.

The game will have 3 types of mode to represent behaviors:
  • Study

  • Socialize

  • Exercise

Study has a subject and whether it is examReview or not.

Socialize has a description and a count of friends to socialize with.

Exercise has a name and whether it is aerobic or not.

There are 3 types of place a student can visit:
  • Classroom

  • Gym

  • StudentCenter

A Classroom has a name, room-capacity and the current occupant-count. The occupant count must be less than the room’s capacity.

A Gym has a name, a count of exercise-machines, the current count of its patrons as well as whether it is open or not. The number of patrons must be less than the number of exercise machines or zero if the gym is closed.

A StudentCenter has a name and whether it is open or not.

A sim-student has a name, mode and a location that is their current place, as well as a gpa and a major.

A student’s location must be Classroom if their gpa is less than 3.0. If their mode is Study then their location must be Classroom or StudentCenter. Similarly, if their mode is Exercise, their location must be Gym.

Name your examples student1, student2 etc., and your examples class ExamplesSims.

We’re placing a lot of restrictions on the data, such as the population of classes and gyms being less than capacity, possible places, etc. However we aren’t (yet) actually enforcing these in the code. The ways to enforce these constraints will be further explored later in the semester. For now, you are expected to create examples that conform to these constraints.

What to submit

You should submit your data definitions and examples in a file named Sims.java

Remember to check the feedback in handins for Style and Checker Tests in handins!