problem 1) Assignment: PipeLayer
In this assignment you would explore use of inheritance and dynamic binding in Java.
You would be provided with the partial implementation of simple game program, written in Java. Your task is to complete the program.
The Lake Gaston Pipeline Game
Construction is underway on pipeline to bring water from Lake Gaston to thirsty Virginia Beach. You are lucky enough to have won contract to lay pipe through the small parcel of land. What's more, your brother-in-law lawyer has wrangled a wonderful contract under which you get paid per unit length of pipe which actually carries water, so it is in your best interest to snake that pipe back and forth as much as you can, so as to get the longest possible working pipeline within your small area of land.
Unfortunately, your pipe supplier delivers whatever shape pipe sections he feels like, and you have to pay for each one delivered, whether you use it or not. Could you lay more water-carrying pipe than you waste in unused pipe sections just lying around on your property?
To play game, follow the instructions below for running the program. At the top of the gameboard you would see the section of pipe which has been delivered. Click in the grid to place the pipe. If the pipe connects with water carrying pipe laid so far, the color would change to indicate that pipe is filling with water, and your score increases.
Running the game
To familiarize yourself with how program is supposed to work, you could run the completed version from the provided jar:
java -jar pipelayer.jar
Select a working directory for your assignment, ensure it is not world readable or executable. Copy the assignment files into that directory.
Files for this assignment are available here or, if you are logged in on our Linux system, at ~zeil/Assignments/cs330/pipelayer/.
Compile source code. (On the Linux system, you could use the provided makefile.
Run this version of the game, and compare to complete game you ran earlier.
As you would note in the previous step, the source code you have been given provides only a single shape of pipe.
You should complete the game, making it behave identically to complete game.
To do this, you must
a) modify PipeKit.java
b) add any extra source code files you wish
but you must not otherwise modify or remove other source code files provided.
If working on Linux, you might also find it to your advantage to modify the makefile by adding to list of CLASSES. For every file Foo.java which you add to the project, add name Foo.class to the CLASSES list in the makefile. [Note that all but the last line of the CLASSES list should end with a backslash \.]
Though, to appreciate how these classes get used in ways that exploit dynamic binding, look at the paint() function in Tile.java or the rescore() function in GameBoard.java.