Mock Objects. Unit-testing and TDD are challenging They require some effort to: – Write a test for a small functionality – Refactor production code and.

Slides:



Advertisements
Similar presentations
Probability and Conditional Probability. Probability Four balls What is the probability of choosing the ball in the red box? Since there are four balls.
Advertisements

Modelling & Datatypes John Hughes. Software Software = Programs + Data.
Discrete Probability Rosen 5.1.
Combinatorics & Probability Section 3.4. Which Counting Technique? If the problem involves more than one category, use the Fundamental Principle of Counting.
Minibridge Cowbridge Comprehensive July 2007 Patrick Jourdain.
Combinations Examples
SOCiable A Game of Life Chances ©Jon Witt Version 1.0.
Lecture 18 Dr. MUMTAZ AHMED MTH 161: Introduction To Statistics.
Modelling & Datatypes Koen Lindström Claessen. Software Software = Programs + Data.
Probability Key. You are given a standard deck of 52 playing cards, which consists of 4 suits: diamonds, hearts, clubs, and spades. Each suit has 13 cards.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 7.9Arrays of Pointers Arrays can contain pointers For.
© Glenn Rowe AC Lab 2 A simple card game (twenty- one)
Counting Techniques 1. Sequential Counting Principle Section
Index Student Activity 1: Questions to familiarise students with the
1 Bridge for Scholars 2009 Presentation 01 2 The deck The deck has 52 cards There are four suits: Clubs , Diamonds , Hearts, Spades  The lowest card.
Describing Probability
Dealer Comm Hand Player makes Ante bet and optional Bonus bet. Five cards are dealt to each player from the shuffler. Five cards are dealt from the shuffler.
Playing Cards Deck of 52 uniquely designed playing cards.
Great Theoretical Ideas in Computer Science.
Probability Of An Event Dhon G. Dungca, M.Eng’g..
1 Probability Parts of life are uncertain. Using notions of probability provide a way to deal with the uncertainty.
1 Section 5.1 Discrete Probability. 2 LaPlace’s definition of probability Number of successful outcomes divided by the number of possible outcomes This.
Intro to Probability & Games
The Game of Ombre Canto 3; lines At the Hampton Palace.
A R R A Y ! for Multiplication!!
VOCABULARY  Deck or pack  Suit  Hearts  Clubs  Diamonds  Spades  Dealer  Shuffle  Pick up  Rank  Draw  Set  Joker  Jack 
1 The game of poker You are given 5 cards (this is 5-card stud poker) The goal is to obtain the best hand you can The possible poker hands are (in increasing.
Refreshing Your Skills for Chapter 10.  If you flip a coin, the probability that it lands with heads up is 1/2.  If you roll a standard die, the probability.
Algorithms. What is an algorithm?  An algorithm is a clear, concise, and correct step- by-step sequence of actions.
Combinations Problems Problem 1: Sometimes we can use several counting techniques in the same problem, such as combinations and the addition principle.
Chapter 11: Counting Methods
Poker Solutions.
Game Rules Rules define game objects and define allowable actions by the players.
Counting. Techniques for counting Rule 1 Suppose we carry out have a sets A 1, A 2, A 3, … and that any pair are mutually exclusive (i.e. A 1  A 2 =
3.8 Counting Techniques: Combinations. If you are dealt a hand in poker (5 cards), does it matter in which order the cards are dealt to you? A  K  J.
6.1 Probability exercises. Def Def: If S is a finite sample space of equally likely outcomes, and E is an event, that is, a subset of S, then the probability.
Tulsa.NET User Group INTRO TO OBJECT ORIENTED PROGRAMMING.
Compound Probability Pre-AP Geometry. Compound Events are made up of two or more simple events. I. Compound Events may be: A) Independent events - when.
Copyright 2013, 2010, 2007, Pearson, Education, Inc. Section 12.2 Theoretical Probability
Chapter 10: Counting Methods
S.CP.A.1 Probability Basics. Probability - The chance of an event occurring Experiment: Outcome: Sample Space: Event: The process of measuring or observing.
Two Way Tables Venn Diagrams Probability. Learning Targets 1. I can use a Venn diagram to model a chance process involving two events. 2. I can use the.
Poker. Basic card terminology Suits: Hearts, diamonds, clubs, spades Deuce, face cards.
15.3 Counting Methods: Combinations ©2002 by R. Villar All Rights Reserved.
What is the Purpose of This Class
Basic Probability Section 7.1. Definitions Sample Space: The set of all possible outcomes in a given experiment or situation Often denoted by S Event:
Homework Homework due now. Reading: relations
Draw 3 cards without replacement from a standard 52 card deck. What is the probability that: 1.They are all red ? 2.At least one is black ? 3.They are.
All In To put all the rest of your money into the pot.
Some other set notation We will use the notation to mean that e is an element of A. We will use the notation to mean that e is not an element of A.
Week 8 : User-Defined Objects (Simple Blackjack Game)
Billion Dollar Baby Game Created By: Timmy Drzewinski Edwin McCracken.
PROBABILITY What is the probability of flipping a head? There is a 1 in 2 chance – ½ = 0.5.
Probability and statistics - overview Introduction Basics of probability theory Events, probability, different types of probability Random variable, probability.
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)
11.9: Solving Probability Problems by Using Combinations
Sequential Placement Optimization Games: Poker Squares, Word Squares, and Take It Easy! Todd W. Neller Abstract: In this talk, we teach how to play “Poker.
Section Combinations (with and without restrictions)
The Addition Rule.
Chapter 10: Counting Methods
Mathematics for Computer Science MIT 6.042J/18.062J
Probability Section 19 NOTE: We are skipping Section 18. 2/21/2019
Combinations.
Term Project: Poker Game
Section 12.2 Theoretical Probability
Section 12.2 Theoretical Probability
Homework Due Friday.
Section 12.2 Theoretical Probability
HOW TO PLAY POKER.
Presentation transcript:

Mock Objects

Unit-testing and TDD are challenging They require some effort to: – Write a test for a small functionality – Refactor production code and tests External dependencies need to be mocked-up – Mocking is not easy

What is mocking Create a fake objectfor which you can – Inspect and set values – Inspect method calls (with args) Used to test interactions with other real objects

Mock example The is a temperature sensor in the real world Testing with a real sensor is cumbersome Need a mock sensor for testing SENSORLOGGER data TEST From Loh Sin Yin 2010

Code example Stock portfolio – Need a market to retrieve the values of the stocks – The service we need (e.g. NASDAQ) is external – Lets mock the real server! Mock objects in Java? EasyMock!

Poker Hands A poker deck contains 52 cards - each card has a suit which is one of clubs, diamonds, hearts, or spades (denoted C, D, H, and S in the input data). Each card also has a value which is one of 2, 3, 4, 5, 6, 7, 8, 9, 10, jack, queen, king, ace (denoted 2, 3, 4, 5, 6, 7, 8, 9, T, J, Q, K, A). For scoring purposes, the suits are unordered while the values are ordered as given above, with 2 being the lowest and ace the highest value. A poker hand consists of 5 cards dealt from the deck. Poker hands are ranked by the following partial order from lowest to highest. – High Card: Hands which do not fit any higher category are ranked by the value of their highest card. If the highest cards have the same value, the hands are ranked by the next highest, and so on. – Pair: 2 of the 5 cards in the hand have the same value. Hands which both contain a pair are ranked by the value of the cards forming the pair. If these values are the same, the hands are ranked by the values of the cards not forming the pair, in decreasing order. – Two Pairs: The hand contains 2 different pairs. Hands which both contain 2 pairs are ranked by the value of their highest pair. Hands with the same highest pair are ranked by the value of their other pair. If these values are the same the hands are ranked by the value of the remaining card. – Three of a Kind: Three of the cards in the hand have the same value. Hands which both contain three of a kind are ranked by the value of the 3 cards. – Straight: Hand contains 5 cards with consecutive values. Hands which both contain a straight are ranked by their highest card. – Flush: Hand contains 5 cards of the same suit. Hands which are both flushes are ranked using the rules for High Card. – Full House: 3 cards of the same value, with the remaining 2 cards forming a pair. Ranked by the value of the 3 cards. – Four of a kind: 4 cards with the same value. Ranked by the value of the 4 cards. – Straight flush: 5 cards of the same suit with consecutive values. Ranked by the highest card in the hand. Your job is to rank pairs of poker hands and to indicate which, if either, has a higher rank. Examples: – Input: Black: 2H 3D 5S 9C KD White: 2C 3H 4S 8C AH Output: White wins - high card: Ace – Input: Black: 2H 4S 4C 2D 4H White: 2S 8S AS QS 3S Output: White wins - flush – Input: Black: 2H 3D 5S 9C KD White: 2C 3H 4S 8C KH Output: Black wins - high card: 9 – Input: Black: 2H 3D 5S 9C KD White: 2D 3H 5C 9S KH Output: Tie