Presentation is loading. Please wait.

Presentation is loading. Please wait.

Elevens Lab Student Material – on website

Similar presentations


Presentation on theme: "Elevens Lab Student Material – on website"— Presentation transcript:

1 Elevens Lab Student Material – on website
The following activities are related to a simple solitaire game called Elevens. You will learn the rules of Elevens, and will be able to play it by using the supplied Graphical User Interface (GUI) shown at the right. You will learn about the design and the Object Oriented Principles that suggested that design. You will also implement much of the code.

2 Elevens consists of four “core” classes, a class that allows the game to be played using a GUI, a small application which initiates the GUI version of the game, and one that simulates the game. A UML diagram is provided below that shows the important inheritance and uses relationships. This diagram also includes three classes for Thirteens, a related game. The classes structure is shown to the right:

3 Explanation of Classes
Card — A playing card. This is a simple class. Deck — A deck of cards. It can shuffle and deal its cards. Board — The 9-card layout. It has all of the board-related game independent methods, as well as the important isLegal and anotherPlayIsPossible abstract methods needed by the GUI. ElevensBoard — The “heart” of the Elevens game. It contains the game-specific code, including the implementations of the isLegal and anotherPlayIsPossible methods. CardGameGUI — The GUI that students can use to play the game. This class is completely implemented and students are not expected to understand that implementation. It can be used, without modification, for different Elevens-related games, including ones with different numbers of board cards. It relies on the specific Board object (such as ElevensBoard) and its isLegal and anotherPlayIsPossible methods to provide the game-dependent behavior. A supplied card folder contains the images used for the displayed cards. ElevensGUIRunner — A simple application that initializes the board, initializes the GUI, and then displays the GUI. ElevensSimulation — Simulates the Elevens game. It uses the ElevensBoard playIfPossible method to provide the Elevens- specific behavior. ThirteensBoard, ThirteensGUIRunner, ThirteensSimulation — The classes for the related Thirteens game.

4 Elevens Lab Wednesday & Friday: Work on Activity 1 & 2

5 In this activity, you will complete a Card class that will be used to create card objects. The starter code is provided. Exercises: 1. Complete the implementation of the provided Card class. You will be required to complete: a constructor that takes two String parameters that represent the card’s rank and suit, and an int parameter that represents the point value of the card; b. accessor methods for the card’s rank, suit, and point value; c. a method to test equality between two card objects; and d. the toString method to create a String that contains the rank, suit, and point value of the card object. The string should be in the following format: rank + “ of “ + suit “ (point value =“ + pointValue + “)”; 2. Once you have completed the Card class, find the CardTester.java file in the Activity1 Starter Code folder. Create three Card objects and test each method for each Card object.


Download ppt "Elevens Lab Student Material – on website"

Similar presentations


Ads by Google