A Casino Simulator Program Using Advanced C++ Concepts Thomas H. Hand July 25 th, 2005 Software/Hardware Integration.

Slides:



Advertisements
Similar presentations
Copyright © 2003 Pearson Education, Inc. Slide 1.
Advertisements

Black Jack in Objective-C
Programming in C Chapter 10 Structures and Unions
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)
Programming Methodology (1). Implementing Methods main.
C Language.
Contents o Introduction o Characteristics of Constructor. o Types of constructor. - Default Constructor - Parameterized Constructor - Copy Constructor.
Chapter 1 Object-Oriented Concepts. A class consists of variables called fields together with functions called methods that act on those fields.
Abstract Classes We often define classes as subclasses of other classes – First, define the superclass – In some cases, a superclass may not have enough.
Craps. /* * file : Craps.java * file : Craps.java * author: george j. grevera, ph.d. * author: george j. grevera, ph.d. * desc. : program to simulate.
Intermediate Visual Basic CISP 371 CRC Prof. Chapman.
Overview Reference parameters Documenting functions A game of craps. Design, code, test and document.
Card Counting What is it, how does it work, and can I use it to pay for college? (and if it does work, do I even have to go to college?) Jeff O’Connell.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 16 – Craps Game Application Introducing Random-Number.
12 Pontoon1May Pontoon program CE : Fundamental Programming Techniques.
Blackjack Programming Project
Rene Plowden Joseph Libby. Improving the profit margin by optimizing the win ratio through the use of various strategies and algorithmic computations.
Design Example. Requirements Make a program that simulates the game of blackjack For now, we ignore money/betting…. just simulate game play But… this.
1 Lab Session-1 CSIT221 Fall 2002 b Refresher slides b Practice Problem b Lab Exercise (Demo Required)
1 Pre-Exam Class CSIT121 Fall 2000 Exam-II (Final Examination) TUESDAY DECEMBER 19th 8:30AM.
OOP Project Develop an Application which incorporates the following OO Mechanisms and Principals: – Classes Visibility Constructor(s) Class Variable (if.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 12 – Craps Game Application: Introducing Random.
CS 117 Spring 2002 Class and Function Reuse derived classes templates.
COMP1170 Midterm Preparation (March 17 th 2009) Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education.
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.
C++ fundamentals.
Fair Games/Expected Value
Passing Other Objects Strings are called immutable which means that once a String object stores a value, it never changes –recall when we passed a message.
April 2009 BEATING BLACKJACK CARD COUNTING FEASIBILITY ANALYSIS THROUGH SIMULATION.
Object Oriented Programming Elhanan Borenstein Lecture #6.
“is a”  Define a new class DerivedClass which extends BaseClass class BaseClass { // class contents } class DerivedClass : BaseClass { // class.
CSE 332: C++ templates This Week C++ Templates –Another form of polymorphism (interface based) –Let you plug different types into reusable code Assigned.
Python File Handling. In all the programs you have made so far when program is closed all the data is lost, but what if you want to keep the data to use.
JokerStars: Online Poker William Sanville CSE 4904 Milestone II.
Method Overriding Remember inheritance: when a child class inherits methods, variables, etc from a parent class. Example: public class Dictionary extends.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 18 - WMLScript: Control Structures II Outline 18.1 Introduction 18.2 Essentials of Counter-Controlled.
What is the Purpose of This Class
Programming Principles Chapter 1. Objectives Discuss the program design process. Introduce the Game of Life. Discuss object oriented design. – Information.
Implementation of the Hangman Game in C++
C++ Programming Basic Learning Prepared By The Smartpath Information systems
Probability Evaluation 11/12 th Grade Statistics Fair Games Random Number Generator Probable Outcomes Resources Why Fair Games? Probable Outcome Examples.
Not So Great Expectations! Which game do you think has the highest return per dollar?
Operator Overloading: indexing Useful to create range-checked structures: class four_vect { double stor[4]; // private member, actual contents of vector.
CIS162AD Inheritance Part 3 09_inheritance.ppt. CIS162AD2 Overview of Topics  Inheritance  Virtual Methods used for Overriding  Abstract Classes and.
CS-1030 Dr. Mark L. Hornick 1 Basic C++ State the difference between a function/class declaration and a function/class definition. Explain the purpose.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 15 Inheritance.
GamblingGambling What are the odds? Jessica Judd.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Craps Game Application Introducing Random-Number Generation and Enum.
 2000 Prentice Hall, Inc. All rights reserved. 5.2Program Modules in C Functions –Modules in C –Programs combine user-defined functions with library functions.
Week 8 : User-Defined Objects (Simple Blackjack Game)
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 16 – Craps Game Application Introducing Random-Number.
Presented by Ted Higgins, SQL Server DBA An Introduction to Object – Oriented Programming.
 2000 Prentice Hall, Inc. All rights reserved Introduction Divide and conquer –Construct a program from smaller pieces or components –Each piece.
POLYMORPHISM Chapter 6. Chapter Polymorphism  Polymorphism concept  Abstract classes and methods  Method overriding  Concrete sub classes and.
Math Puzzles and Game Theory Final Exam Work through the slides, follow the directions, and fill in all required information.
Obey Gravity Update Java Code, Layouts, Assets, Source/Version Control By: Team Artificial Gravity.
1 Inheritance and Polymorphism Chapter Getting Started Continue the Cat Management example from previous presentation.
 Virtual Function Concepts: Abstract Classes & Pure Virtual Functions, Virtual Base classes, Friend functions, Static Functions, Assignment & copy initialization,
Electronic Craps Table. Objective Design a system to incorporate electronics into the game of craps to track bets and payouts while maintaining the interactive.
Georgia Institute of Technology More on Creating Classes Barb Ericson Georgia Institute of Technology June 2006.
Object-Oriented Concepts
Inheritance AKEEL AHMED.
Probability of casino games
Task 2 Implementation help
CIS 199 Final Review.
More on Creating Classes
Eighth step for Learning C++ Programming
ENERGY 211 / CME 211 Lecture 30 December 5, 2008.
BY: Cesar, Jennifer, Adrianne & Allen
Presentation transcript:

A Casino Simulator Program Using Advanced C++ Concepts Thomas H. Hand July 25 th, 2005 Software/Hardware Integration

Overview of Presentation  Background Concepts & Motivation  Program Flowchart  Advanced C++ Concepts Utilized  Explanation of Program  Conclusions and Questions

Background Concepts & Motivation The purpose of this project was to create a program that would simulate several casino games, while giving the player the ability to save and load data. In addition, the program incorporates just about every concept learned in the Advanced C++ course. As these concepts arise during the program explanation, I will inform you of them.

Program Flowchart - PLEASE SEE VISIO FLOWCHART -

Advanced C++ Concepts Utilized  Classes  Operator Overloading  Polymorphism  Inheritance  File Processing  Data Structures  Some STL concepts

Explanation of Program  Five Header Files contain the class definitions: mainprogram.h blackjack.h craps.h poker.h slotmachine.h

mainprogram.h: Public Members:  Main source of control for program flow  Contains class mainprogram which is a base class to classes: blackjack, craps, poker, and slotmachine virtual void menu() const: This member function displays the opening screen with the menu selection, and is const because it is not to modify any data. virtual int play(): In mainprogram, this member function does nothing. It is declared virtual because all of the classes derived from class mainprogram use function play to initialize the corresponding games. Therefore, play must be overridden in each derived class. This is how “Polymorphism” is used in my program.

void newgamedisplay() const: This member function displays the game selection screen, and is called when the player selects “new game” from the main menu display. int decision(): This member function returns a value that corresponds to the player’s input. It returns either 1,2,3,4, or 5, which corresponds to starting a new game, saving the current game, loading a game, viewing the high scores, or quitting. void loadgame(): This member function allows the player to load one of five saved games. void savegame(): This member function allows the player to save the current game into one of five save files.

void highscores(): This member function allows the player to view the scores of each save file in descending order. void quit() const: This member function is used to quit the program completely. int getchoice(): This member function allows user to select which game they want to play int getwins(): This member function accesses private data member totalwins and returns the current number of wins. int getlosses(): This member function accesses private data member totallosses and returns the current number of losses.

int getmoney(): This member function accesses private data member totalmoney and returns the current amount of money. int setwins(): This member function is used to increment the number of wins in the current game (modifies private member totalwins). int setlosses(): This member function is used to increment the number of losses in the current game (modifies private member totallosses). int setmoney(int): This member function is used to change private data member totalmoney void timedelay(): This member function is used for a time delay

Private Data Members:  mainprogram is the heart of the casino simulation. At over 600 lines of code, it is the “brain” of the project int totalwins: used to keep track of the total number of wins. int totallosses: used to keep track of the total number of losses. int totalmoney: used to keep track of the total amount of money

blackjack.h  Contains black jack game class definition  Publicly Inherits from class mainprogram Public Data Members: virtual int play(): This member function is used to load the game menu and get input from player. It is declared virtual so that it can override mainprogram’s play() function.

int init(): This member function is used to start a new game of blackjack. void shuffle(): This member function shuffles the card arrays into a random order. void shuffle2(): This member function is used to fill the 52-card array with cards. void display(): This member function is used to display the current dealer and player hands.

void input(): This member function is used to ask the player if they want a card. int process(): This member function checks for the outcome of the game and returns a value dependent on if the player won or lost.  Blackjack simulates a standard blackjack game, where 21 is a blackjack. A natural blackjack is when the player is dealt a blackjack from the start.

craps.h:  Contains craps game class definition  Publicly Inherits from class mainprogram Public Data Members: virtual void menu() const: This member function displays the craps opening menu. It is declared virtual because c-menu() must override mainprogram’s menu() function. virtual int play(): This member function starts the craps game simulation. It is declared virtual so that it overrides mainprogram’s play() function.

int rolldice(): This member function simulates the roll of two die and returns their sum. void timedelaycraps(): This member function causes a time delay used by the craps game.

poker.h  Contains poker class definition  Publicly Inherits from class mainprogram Public Data Members: virtual void menu() const: This member function displays the poker opening menu. It is declared virtual because p->menu() must override mainprogram’s menu() function. virtual int play(int): This member function handles the game logic of five card stud poker. It takes the current value of totalmoney and returns a new value to be used for the current amount of money the player has.

virtual pokertimedelay(): This member function implements a time delay for use in the poker game.

slotmachine.h  Contains slotmachine class definition  Publicly inherits from class mainprogram Public Data Members: virtual void menu() const: This member function displays the slotmachine opening menu. It is declared virtual because sm-menu() must override mainprogram’s menu() function. virtual int play(int): This member function starts the slotmachine game and returns the new “totalmoney” value. void slottimedelay(): This member function implements a time delay used by the slotmachine game.

Source Files The Source Files are too detailed to explain here. Please see the code comments for an in-depth explanation. The following source files are utilized in my program: main.cpp blackjack.cpp craps.cpp poker.cpp slotmachine.cpp

Conclusions and Questions Any Questions?