Inheritance and interfaces to construct type hierarchies, JAVA Programming


1. To help you become comfortable with using inheritance and interfaces to construct type hierarchies.

2. To familiarize you with programming from specifications.

As per usual practice, any input files will be placed in the same directory as your program during grading. (Don't forget how Eclipse/NetBeans handle these things if you use one of those IDEs.)
Problem: Adventurer Assistance, Inc.

Fresh from your successful internship with the famed explorer Tallahassee Smith, you've spotted a market opportunity and decided to go into business for yourself. Your startup, Adventurer Assistance, provides online guidance to teams of adventurers in sticky situations. Your first contract involves providing mission control for teams of three exploring underground cave systems suspected to have been built by aliens, dwarves, the Great Old Ones, or perhaps even all three. Their aim is to reach a treasure cache whose location they have identified. But first they need to navigate through the dark and treacherous caves, and helping them do that right is your job.

Your helpful assistants have already written a graphical user interface for your program, and provided a set of specifications for classes that you must write in order to make it work. When you're done, you'll be able to send commands to the three team members, simply by clicking on their icons and moving them around with arrows. This allows you to trick online gamers into guiding expeditions, by having them think they're playing a 2-D maze game instead.

In practical terms, you will not write a main() method at all, just the functionality that main() already expects in order to function. In effect, you're writing a library to be used by the prewritten GUI code.

The caves are laid out in a regular two-dimensional grid pattern, which you have named the Board. Each cell of the grid represents a single cave in the cave system. A cave is big enough to hold exactly one person (the builders were apparently rather small), and is connected to its four neighboring caves to the North, South, East and West.

However, not all caves are accessible. While some caves are open, others may have been blocked by a cave-in, and cannot be entered. Some others contain bottomless pits that will be the end of any unwary explorer that walks into them. And finally, certain caves are teleport locations that will instantly transport anyone who enters to a random open cave anywhere on the Board. These are especially problematic because we usually can't tell where they are, except by entering and getting teleported.

A team is composed of three people, with unique specialties:

1. Miner: A demolition expert. If he moves into a location with a cave-in, he will destroy the rocks blocking it off, converting it into an open cell.

2. Filler: A vertical descent safety specialist who can fill in bottomless pits. If he enters a location with a pit in it, the pit will be filled in and the cave will be considered open.

3. Adventurer: The intrepid leader of the expedition. She is the one who must reach the treasure cache in order to achieve mission success, because the other two don't look as good on camera, and 21st century adventuring is really all about the post-adventure merchandising deals. She is equipped with a cutting-edgeTeleport Interdiction System. As a result, if she enters a teleport location, she will not get teleported. Instead, that location will be marked on the Board, so that the other two can avoid it (or risk it, if necessary). Unfortunately, she can't enter blocked-off caves, and will be killed if she walks into a cave with a pit in it. If she dies, the mission ends, and is considered a failure.

Neither of these three can leave the cave - the boundaries are impenetrable. The only way out is to get the Adventurer to the treasure in the bottom-right corner of the Board.

At the start of the game, a random board is generated. (The reason for this is complicated, and involves a series of unfortunate accidents involving a time machine and a random number generator.) The Adventurer is at the top-left location, and the Miner and Filler are at random open caves on the Board, having gone in earlier. Such is life for a professional sidekick.

To model this situation, you must write the following set of classes. (See documentation for precise technical details on what you should implement.)

1. Cave: A class that represents a single cave. Its instance variables contain information on its position on the Board, the type of cave it is (open, blocked, pit, teleport), and various instance methods described fully in the docs.

2. Board: Represents the game board. It contains a 2-D array of Caves, and is responsible for generating a random cave system, among other things.

3. Character: An abstract base class representing members of the team. It handles common functionality, like moving from a cave to an adjacent cave and getting teleported if it contains a teleport location. The classesAdventurer, Miner and Fillerare descended from it, and override its methods to model their unique behavior.

4. Adventurer: A subclass of Character that represents the leader of the expedition. Incorporates the special ability to be immune to teleportation and mark teleport locations.

5. Miner: A subclass of Character that represents the miner, and incorporates his special ability to clear blocked caves.

6. Filler: A subclass of Character that represents the filler, and incorporates his special ability to fill up pits.

7. CaveWorker: An interface that represents the ability to change a non-open location to an open one (by filling a pit or blowing up rocks).

You will be provided with the main class AdventureGamethat will generate the game interface and handle input/output. You DO NOT need to alter this file for the normal assignment. (See the extra credit section below for the situation where you might want to alter it.)

The folders icons and icons64 provided for you must be placed in your project folder. The image files in them are used as part of the GUI.

You don't need to worry about input/output, this will all be handled by the prewritten classes we will provide.

Extra Credit (Optional)

An additional Webcourses assignment will be created, marked Assignment 4E. This is the extra credit assignment. On this one, you can add new features, overhaul the GUI, soup up the game in crazy ways - basically be as creative as you want. Up to 20 points of extra credit are available for this, which comes to 7 extra points added to your final grade at the end of class. We'll show off the coolest submissions in class.

NOTE:You still need to submit the original assignment! Please avoid adding extra features to the original one - reserve your creativity for the extra credit.


Submit the source files over Webcourses as an attachment. In particular, do not submit any .class files!!! This will result in 0 credit for the assignment. You must send your source files as an attachment using the "Add Attachments" button. Assignments that are typed into the submission box will not be accepted.

Your program must compile using Java 6.0 or later on the command line. Your programshould include a header comment with the following information:

Your name

Course number, section number

Short description of the code

Posted Date: 3/26/2013 4:16:45 AM | Location : United States

Related Discussions:- Inheritance and interfaces to construct type hierarchies, Assignment Help, Ask Question on Inheritance and interfaces to construct type hierarchies, Get Answer, Expert's Help, Inheritance and interfaces to construct type hierarchies Discussions

Write discussion on Inheritance and interfaces to construct type hierarchies
Your posts are moderated
Related Questions
It helps to resolve naming conflicts when different packages have classes with the same names. This also helps you prepare files within your project. As define : package

What is Arithmetic promotion assignment and casting? In an assignment statement, i.e. if there's an equals sign, Java compares the type of the left hand side to the at last typ

Running a sample Java web application from the web get http 404 error

Authentication is basically an identification step. Functionality used for J2EE security: Principal : An entity that may be authenticated and identified. Principal n

What is the difference among using bind() and rebind() methods of Naming Class? Ans) Bind method (String name) binds the specified name to a remote object whereas rebind(String

Explain unicode in java? Java uses the Unicode character set. It is a two-byte character code set which has characters representing almost overall characters in almost all huma

Describe The ? operator in Java langauge? The conditional operator just works for assigning a value to a variable, using a value within a method invocation, or in a few other w

Consider the following code? What input is needed for x in order for the sum variable that is output at the end of the code to be 12 ? (In other words: what do I need to make X be

Difference between the File and Random Access File classes? Ans) The File class encapsulates the files and directories of the local file system. The Random Access File class giv