Assignment 5: Image Files and Fishy
Goals: Practice function objects over lists and design a medium-sized world program.
Instructions
This assignment has two independent submissions:
Homework 5 Problem 1: One ZIP file named ImageFiles.zip, containing the ImageFile classes, methods, and tests.
Homework 5 Problem 2: One ZIP file containing the Fishy source and image files, UserGuide.txt, and Design.txt.
Mastery Check 6: Homework 5 code walk
Complete and submit both problems with your partner. The ImageFiles submission determines your autograded Homework 5 score. The submitted Fishy program is a course artifact used for Mastery Check 6; it receives no separate line-by-line, style, or extra-feature grade.
The Fishy autograder score out of 10 reports basic submission and execution checks only. It does not contribute to your homework, code-walk, or final grade. The Fishy submission remains required for the separately graded code walk. Passing these checks does not establish that all game requirements are satisfied.
Each pair must make one booking through the Fishy code-walk booking page for one approximately ten-minute appointment block. That page lists the current dates and times. The student who makes the booking must provide both partners’ names and SHU email addresses; if you are working alone, enter solo for the partner information. Both partners must attend. Within the shared appointment, the pair will first open the submitted programs and run one requested example. Then each student will be assessed individually with different prompts: be ready to explain an instructor-selected part of either submitted problem and to trace, diagnose, or make a small change. You may use your submitted code and the tools normally available to you, including AI. During the walk, neither partner may speak to, signal, or assist the other; respond only to the instructor. Tool output by itself is not evidence of your understanding. If one partner is absent, the attending partner can still complete the walk and receive an individual score.
The explanation prompt and the trace, diagnosis, or change prompt are equally weighted. Each receives 2 for satisfactory evidence of the requested skill, 1 for meaningful but incomplete evidence, or 0 for no usable evidence. Together, the two scores determine the separately weighted code-walk grade described in the syllabus. Speaking polish, speed, and a particular program design are not scoring criteria.
Select one of the posted blocks rather than arranging an appointment piecemeal by email. If a documented conflict or approved accommodation makes the published booking options unusable, contact the instructor before the first appointment begins to arrange an equivalent format. An unarranged no-show earns zero for the code walk under the syllabus policy; there is no routine redo or bespoke makeup.
1 Problem 1 — ImageFile function objects
Use the following data and exact interface names:
class ImageFile { String name; int width; int height; String kind; ImageFile(String name, int width, int height, String kind) { ... } } interface ISelectImageFile { boolean apply(ImageFile file); } interface ILoIF { boolean contains(ImageFile file); ILoIF filterImageFile(ISelectImageFile predicate); boolean allSuchImageFile(ISelectImageFile predicate); } class MtLoIF implements ILoIF { ... } class ConsLoIF implements ILoIF { ... }
Complete and thoroughly test all of the following work:
Design SmallImageFile, an ISelectImageFile function object that accepts images smaller than 40,000 pixels.
Design NameShorterThan4, an ISelectImageFile function object that accepts images whose names have fewer than four characters.
Design GivenKind, whose constructor accepts a file kind and whose apply method accepts images of that kind.
Implement allSuchImageFile for lists of image files.
Implement filterImageFile for lists of image files, preserving the order of all accepted images.
2 Problem 2 — Fish Feeding Frenzy
Design a version of Fishy. The player begins as a small fish among both smaller and larger fish. The player survives by eating smaller fish and avoiding larger ones, and wins after becoming larger than every other fish in the pond.
Your game must:
Use one or more classes to represent the player and background fish, and use a list or other collection rather than a fixed number of fish.
Move the player with the arrow keys.
Move background fish across the screen from one side to the other. The player fish must wrap from one side of the screen to the other.
Determine when the player overlaps and can eat a smaller fish.
End the game as a loss when the player is eaten by a larger fish.
End the game as a win when the player is larger than every remaining fish.
Grow the player in proportion to the sizes of the fish it eats.
Thoroughly test all behavior other than image-producing methods.
Code and submission requirements
Name your world class FishyWorld and have it extend javalib.funworld.World. Provide these two constructors:
FishyWorld() creates a fresh game ready to play.
FishyWorld(Random rand) creates a fresh game ready to play, using the supplied java.util.Random object for all random decisions. This lets the same seed and sequence of game events reproduce a run for testing.
Both constructors must initialize a complete starting game without opening a window. To play, construct the world and then call bigBang on it, as in the course examples. You may add other constructors as your design requires. The instructor tests will use these constructors and the World library’s scene, tick, and key methods. Design the remaining classes, fields, and helper methods yourself.
Submit all source and required assets, using paths relative to the submission folder. Your program must compile with the supplied course libraries. Put your Java source files, UserGuide.txt, and Design.txt at the top level of the ZIP; assets may be in subfolders. Use the default package, with no package declarations.
Do not make the game elaborate at the expense of its design. Include a short UserGuide.txt explaining how to play and a Design.txt describing the purpose and relationships of the classes.
Optional extensions
Possible extensions include movement inertia, size-dependent acceleration, scoring, size bonuses, and speed bonuses. Any extension must remain well-designed and tested. Optional extensions earn no additional points.