CSE 115 - Spring 2010 - Banner
UB -
University at Buffalo, The State University of New York Computer Science and Engineering
  • CSE 115 - Spring 2010
CSE 115 - Spring 2010 - Navigation
CSE 115 - Spring 2010 - Announcements

Lab 7

CSE 115 - Spring 2010 - Lab 7

Introduction

It's time to start thinking bigger. It's time to start thinking strategically. It's time for the home-stretch. Over the course of the next three labs, you will be building the implementation for a fully-playable game of battleship. The labs will build off of each other, but each will leave the game at a unique state.


Lab Functionality Description

When the game starts, it will look no different that at the end of Lab 6. Clicking on the opponents board should still cause the same message to appear on the screen.

However, the GameEngine now incorporates the use of a game state. This state (which you will create as a subclass of AShipPlacementState) is a state which allows ships to be placed until all five ships are on the screen. The TAs will be discussing this notion of state in recitation this week.

If the players clicks on the player's board, an error should be generated if they did not first click on a ship. This error can happen at the beginning of the game, or at other times during the ship-positioning process. An error is simply an error message displayed to the message area.

When the user clicks on a ship button, that ship is placed in the holder. The listener for the ship buttons should only set the ship in the holder (and do nothing else). Subsequently clicking on the board will place the ship currently in the holder on the board. Remember that ships can be placed vertically or horizontally. When a ship is placed on the board, you should no longer be allowed to add additional ships of that same type to the board. (Simply disabling the buttons for the ship would accomplish this task).

When all five ships have been placed, the game should go into a state that does not allow further ships to be placed. Clicking on the board when the game is in this state should cause a message to be displayed to the message area indicating that there are no longer any ships to place.

Note that ships should not be allowed to be placed on top of each other and that if you try to place a five-shot ship on a square that is less than five cells away from the edge of the board, it should not be allowed. (Similar behavior should not be allowed for the other sizes of ships.) Note that either of these must cause an error message should be displayed in the message area.

In this stage of the game, you must begin storing information about ship location in a collection. Your solution must contain a java.util.HashMap for this task.

 

Some General Design Notes and Tips

Your ship class should replace the AShip class in the skeleton.

There are some new methods in IGame and IGameEngine that you will need to make sure to implement.

The listeners on the game boards should only talk to the game engine, not to the game.

Take a look at the DrawingCanvas class. You will note some potentially useful methods for drawing lines on a canvas that Joe has just added to that class.


Lab Tasks

Check out the lab skeleton.

You will need to move some of your files from Lab 6 into the Lab 7 project (by copying and pasting them). For other files, you will need to move your functionality from Lab 6, but leave some of the new implementation in the file. You will need to read each file to determine whether it should be replaced or your code should be inter-twined with the new file.

You should make sure that you have a working Lab 6 before moving on to the implementation of Lab 7.

If for whatever reason you did not get a working implementation of Lab 6, then you should stop by one of the staff's office hours to have them look at your implementation to see if problems can be fixed. You will not be able to have a successful Lab 7 implementation without a working Lab 6 implementation. Therefore, you need to make sure to see a staff member to get a working Lab 6 implementation before moving on to a Lab 7 implementation. If you are unable to make schedule office hours, then you should email Adrienne with a comprehensive list of your available times to set up a meeting to look at your Lab 6 code.


Due dates

You will submit your Lab 7 assignment using the Web-CAT submission plugin from Eclipse. Lab 7 is due the day before your recitation meets the week of April 12th. You will be using your Lab 7 code for Lab 8.


CSE 115 - Spring 2010 - Footer

Page maintained by Adrienne Decker

Contact: adrienne@buffalo.edu | 130 Bell Hall | (716)645-3184