12 Pontoon1May 15 12 Pontoon program CE00858-1: Fundamental Programming Techniques.

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

ECE 491 Final Project Multiplayer Card Game Author: Tian Ma Presentation 5/4/2004.
SOCiable A Game of Life Chances ©Jon Witt Version 1.0.
Java Coding 8 David Davenport Computer Eng. Dept., Bilkent University Ankara - Turkey. Object-Oriented Design Example - The.
© Glenn Rowe AC Lab 2 A simple card game (twenty- one)
It’s All in the Cards Adding and Subtracting Integers
04 WeightLoss program1May WeightLoss program CE : Fundamental Programming Techniques.
Lecture 10. Simplified roulette European roulette has numbers 0,1,…36. xD0s
08 Deterministic iteration1May Deterministic iteration CE : Fundamental Programming Techniques.
Top-Down Design CSC 161: The Art of Programming Prof. Henry Kautz 9/16/2009.
Activity 1: Where am I? Play in pairs Each player has a number line or bead string and a pack of number cards Each player takes turns to turn over a number.
CS161 Topic #11 1 Today in CS161 Lecture #11 More Functions Write Programs using Functions Black Jack (add the dealer and make corrections) Arguments Now.
Blackjack Programming Project
Computer Science 313 – Advanced Programming Topics.
Design Example. Requirements Make a program that simulates the game of blackjack For now, we ignore money/betting…. just simulate game play But… this.
03 Data types1June Data types CE : Fundamental Programming Techniques.
06 Testing selection1June Testing selection CE : Fundamental Programming Techniques.
Random (1) Random class contains a method to generate random numbers of integer and double type Note: before using Random class, you should add following.
Intro to Probability & Games
18 File handling1June File handling CE : Fundamental Programming Techniques.
11 Methods1June Methods CE : Fundamental Programming Techniques.
Chapter 5 Black Jack. Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 5-2 Chapter Objectives Provide a case study example from problem statement.
Lecture 5 of Computer Science II Arrays Instructor: Mr.Ahmed Al Astal.
10 ThinkOfANumber program1July ThinkOfANumber program CE : Fundamental Programming Techniques.
A R R A Y ! for Multiplication!!
o Simulate a deck of playing cards o Shuffle the deck o Deal (5) cards into the hand o Turn over the first card o The user must guess whether the next.
o Simulate a deck of playing cards o Shuffle the deck o Deal 5 cards into the hand o Turn over the first card o The user must guess whether the next card.
VOCABULARY  Deck or pack  Suit  Hearts  Clubs  Diamonds  Spades  Dealer  Shuffle  Pick up  Rank  Draw  Set  Joker  Jack 
Black Jack Dr. Bernard Chen University of Central Arkansas Spring 2012.
Lecture 15 Practice & exploration Subfunctions: Functions within functions “Guessing Game”: A hands-on exercise in evolutionary design © 2007 Daniel Valentine.
CS161 Topic #15 1 Today in CS161 Lecture #15 Practicing! Writing Programs to Practice Write a game program (1 player) of Mad Math Reuse the functions to.
Learning to Play Blackjack Thomas Boyett Presentation for CAP 4630 Teacher: Dr. Eggen.
MOM! Phineas and Ferb are … Aims:
Iteration. Adding CDs to Vic Stack In many of the programs you write, you would like to have a CD on the stack before the program runs. To do this, you.
11 Finding Winners Using Arrays Session 8.2. Session Overview  Find out how the C# language makes it easy to create an array that contains multiple values.
DiceRoller DiceRoller (object class) and DiceRollerViewer client class: Write a DiceRoller class (similar to Yahtzee) to: Allow the person to initially.
Do Now 9/28/10 Take out your HW from last night. Take out your HW from last night. Textbook page 31-32, #3-11, all Textbook page 31-32, #3-11,
Mathematical Games Monken Hadley Friday 8 th March 2013.
Main Program Repeat call InitialiseVar # a procedure to reset all variables call ShufflePack# a procedure to generate a random list of 52 cards call PlayerGo#
Pitch Playing Agent Project for Into to AI Jody Ammeter.
Expected Value. Expected Value - Definition The mean (average) of a random variable.
Making Decisions uCode: October Review What are the differences between: o BlueJ o Java Computer objects represent some thing or idea in the real.
Discussion 4. Labs public MyPoint(double xInit, double yInit ) { MyPoint p = new MyPoint(0, 0); } ClassProblem.java recursive java.lang.StackOverflowError.
Georgia Institute of Technology More on Creating Classes part 2 Barb Ericson Georgia Institute of Technology Oct 2005.
Dr. Soha S. Zaghloul2 Let arr be an array of 20 integers. Write a complete program that first fills the array with up to 20 input values. Then, the program.
UFCEKS-20-2Multimedia Authoring Times Table Quiz.
More loops while and do-while. Recall the for loop in general for (initialization; boolean_expression; update) { }
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
Random Numbers Random numbers are extremely useful: especially for games, and also for calculating experimental probabilities. Formula for generating random.
Week 8 : User-Defined Objects (Simple Blackjack Game)
UFCFY5-30-1Multimedia Studio Scripting for Interactive Media Times Table Quiz This will contribute towards your online portfolio for this module.
14 BirthMonth1February BirthMonth CE : Fundamental Programming Techniques.
More on Logic Today we look at the for loop and then put all of this together to look at some more complex forms of logic that a program will need The.
Card Game Z  Agree on a dealer and a score keeper  The dealer should remove all the Jacks, Queens, Kings & Jokers from the pack and then shuffle  The.
Georgia Institute of Technology More on Creating Classes Barb Ericson Georgia Institute of Technology June 2006.
Texas Holdem A Poker Variant vs. Flop TurnRiver. How to Play Everyone is dealt 2 cards face down (Hole Cards) 5 Community Cards Best 5-Card Hand Wins.
Arrangements and Selections (and how they may be counted)
Lecture 11.
Chapter 5 Black Jack.
@NAMEOFEVENTORBRIDGECLUB
Lecture 10.
Probability of casino games
Truth tables: Ways to organize results of Boolean expressions.
Coding Concepts (Basics)
Truth tables: Ways to organize results of Boolean expressions.
Games Workshop.
Truth tables: Ways to organize results of Boolean expressions.
Task 2 Implementation help
Dry Run Fix it Write a program
Presentation transcript:

12 Pontoon1May Pontoon program CE : Fundamental Programming Techniques

12 Pontoon2May 15 Objectives In this session, we will: analyse a problem that uses methods implement the solution using concepts introduced so far

12 Pontoon Pontoon specification a simple game based upon the card game Pontoon player will play the game against the computer cards are allocated numeric values Ace = 11, Jack = 10, Queen = 10, King = 10 although in Pontoon, Ace can be either 11 or 1, we will only use 11 Cards have their face value player and computer are dealt two cards in turn initially then can take additional cards player takes all additional cards before computer computer must take additional cards if score less than 15 score over 21 "busts" winner has highest score that is 21 or under computer's score beats player's if equal May 153

12 Pontoon Analysis – break down relatively large problem break down into smaller chunks analyse, implement and test each chunk: deal initial hands deal additional cards to player check if player bust deal additional cards to computer check if computer bust check for winner also need to consider how to represent cards May 154

12 Pontoon //play a game of pontoon import java.util.*; public class Pontoon { public static void main (String args[]) { //deal initial hands //deal additional cards to player //deal additional cards to computer //check if anyone bust //check for winner if no-one bust } May 155

Representing cards each card has a rank and an integer score not concerned with suit of card value is randomly generated need to: output rank based on value determine score based on value 12 Pontoon6May 15 ValueRankScore 1Ace11 2 – 10 face value 11Jack10 12Queen10 13King10

12 Pontoon Testing: Deal initial hands add output statements to display scores after each card dealt run program and ensure: 2 random card values generated for player 2 random card values generated for computer rank displayed correctly scores calculated correctly May 157

12 Pontoon Testing: Deal additional cards to player run program and ensure: user asked whether they want new card after initial hand dealt loop entered when user first types 'y' loop continued when user next types 'y' loop terminated when user types anything else May 158

12 Pontoon Testing: Deal additional cards to computer add statement to set computerScore to 0 before loop run and ensure loop is entered at least twice change statement to set computerScore to 14 run and ensure loop is entered when score is 14 (boundary case) change statement to set computerScore to 15 run and ensure loop is not entered when score is 15 (boundary case) remove added statement May 159

12 Pontoon Testing: Check if anyone bust add statement to set player’s score to 21 before checking to see if anyone bust run program and ensure player doesn’t bust change statement to set player’s score to 22 run program and ensure that player busts remove statement add statement to set computer's score to 21 before checking to see if anyone bust run program and ensure computer doesn’t bust change statement to set computer's score to 22 run program and ensure that computer busts remove statement May 1510

12 Pontoon Testing: Check win add statements after checking if anyone bust to set player’s score and computer’s score so that player's score is higher than computer's run program and ensure that player wins change statements so computer's score and player's score are equal run program and ensure that computer wins change statements so computer's score is higher than player's score run program and ensure that computer wins remove added statements May 1511

12 Pontoon12May 15 Summary In this session we have: analysing a fairly large problem to determine what is required implementing a solution that: generates random numbers uses while loops uses if statements uses methods to implement parts of the solution In the next session we will: use arrays to store data