Vous êtes sur la page 1sur 14

AP Computer Science

Elevens Lab
Luke Butler, David Mustard and David Patrick
Introduction
Goal: Create a solitaire game called elevens.

Elevens: Nine cards are placed on the board. If two of the cards add up to eleven, they are removed. If all
three of the royal cards (King, Queen, Jack) are found on the board, they are removed and replaced with
other cards from the deck. The goal of the game is to remove all cards from the board. If there is nothing
that adds up to eleven, the game is lost.
Activity 1-Create a Card Class
● Created a constructor that took in two String parameters(rank and suit) and an int parameter that
represents the point value of the card.
● Created separate accessor methods for the card’s rank, suit, and point value
● Created a method to test equality between two card objects
● Created a toString method to print rank, suit and point value of a card object.
Activity 2-Implement a Deck Class
● Created a deck constructor that receives the rank, suit, and point value arrays as parameters
● Created an isEmpty method to tell if the deck is empty or not
● Created a size method that details the number of cards left in the deck
● Created a deal method to put cards from the deck onto the board
Activity 3-Shuffling the Deck
● Implemented the Shuffler.java file to create the perfect shuffle
● Tested how well the Shuffler.java file randomizes the deck
Activity 4-Add a Shuffle Method to the Deck Class

● Added the Shuffle Method created in Activity 3 to the Deck Class created in Activity 2
Activity 5-Testing With Assertions
This was an optional section and the starter code was not adequate to create the desired tests.
Activity 6-Playing Elevens
● Ran the file Elevens.jar to play elevens

Activity 7-Design ElevensBoard Class
● This Class will contain the state(instance variables) and behavior(methods) necessary to play
elevens.
Activity 8-Using an Abstract Board Class
● Created another card game called thirteens
● Created another card game called tens
● Use a common superclass for all three games
Activity 9-Implementing Elevens Board
● Implemented isLegal method to check the number of cards in the ElevensBoard helper methods
● Implemented anotherPlayIsPossible method which returns true if there are any other legal plays
on the board
● Implemented containsPairSum11 method to determine if the selected number of cards contain any
that add up to 11 and can be removed
● Implemented containsJQK method which determines if the selected number of cards contain a
Jack, Queen and King that can be removed
Activity 10
● Changed the ElevensBoard class effectively to create a ThirteensBoard game

Thirteens:This game has a ten card board. Ace is given the value of one and Queen and Jack are given the
values of 11 and 12 respectively, other cards are given point values corresponding to their face value.
Cards can be removed if they add up to 13. Kings are removed singly.
Activity 11-Create a Simulation of Elevens
● In this activity we create a simulation where we can run very many different games of Elevens, so
we will be able to create opinions about the win rate of Elevens
● Changed method containsPairSum11 and containsJQK to findPairSum11 and findJQK which
returned lists instead of booleans
● Changed isLegal and anotherPlayIsPossible method to use the findPairSum11 and findJQK
Conclusion-Presentation Skills/Collaboration

Vous aimerez peut-être aussi