1 Instructions
Practice Problems
Problem 1:   Understanding the String class
Problem 2:   Abstracting over Data Definitions
Problem 2:   Using Libraries:   Designing Interactive Games

Assignment 3: Abstracting over Data Definitions; Designing Games

Goals: Learn to use the Sting class, practice working with lists. Learn to design abstract classes and class hierarchies. Design an interactive graphics-based game: Using libraries.

1 Instructions

The names of the classes must be exactly the same as specified. The same is the case for the names and types of the fields within the class, as well as the order in which they are defined and listed as the constructor arguments. This allows us to design our own Examples class that tests your program.

Make sure you follow the style guidelines that WebCAT enforces. For now the most important ones are: using spaces instead of tabs, indenting by 4 characters, following the naming conventions (data type names start with a capital letter, names of fields and methods start with a lower case letter), and having spaces before curly braces.

You will submit this assignment by the deadline using the Web-CAT submission system. You may submit as many times as you wish. Be aware of the fact that close to the deadline the WebCAT system may slow down to handle many submissions - so try to finish early.

With each homework you will also submit your log file named pair-user1-user2.txt where you replace user1 and user2 with the usernames of the two partners.

On top of both files you will have five lines of comments as follows:

// assignment 1

// partner1-last-name partner1-first-name

// partner1-username

// partner2-last-name partner2-first-name

// partner2-username

(In the text file you do not need the two slashes)

Your submission sould consist of the following files:

all combined into one HW3.zip file.

Due Date: Monday, October 7th, 10: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: Understanding the String class

For this problem start with the file Strings.java that defines a list of Strings.

Note: The following method defined for the class String may be useful:

// does this String come before the given String lexicographically?

// produce value < 0   --- if this String comes before that String

// produce value zero  --- if this String and that String are the same

// produce value > 0   --- if this String comes after that String

int compareTo(String that)

Problem 2: Abstracting over Data Definitions

A file in a computer can contain either a text, or an image, or an audio recording. Every file has a name and the owner of the file. There is additional information for each kind of file as shown in the program Files.java

Download the file and work out the following problems:

Save the work you have done. Copy the file and continue. (Do not submit this part of your work.)

Possibly start a new project and import the file Files.java into it. Alternatively, save the a copy of the file you have been working on in another folder.

Hand in the result of this part of the assignment only.

Note: You can lift the method sameOwner only if you change its contract. Do so — make sure you adjust the test cases accordingly.

Problem 2: Using Libraries: Designing Interactive Games

Design a simple interactive graphics-based game that extends the World class in the javalib.funworld library and performs some actions on each tick, and responds to some user’s key events.

The game should have at least one collection of objects in it.

It should have some random behavior.

It should not be overly complicated, but have options for later additions.

For your submission besides the code for your game and all of the necessary examples and tests, you should include:

Additional instructions for how to organize and submit your work will be available early next week.