Escolar Documentos
Profissional Documentos
Cultura Documentos
h
// Project5
//
// Created by Howard Stahl on 1/11/16.
//
#ifndef POWERBALLLOTTERY_H
#define POWERBALLLOTTERY_H
#include "PowerballTicket.h"
class PowerballLottery
{
public:
PowerballLottery( );
PowerballLottery( int ball1, int ball2, int ball3, int ball4, int ball5, int powerb
all );
int
int
int
int
int
getBall1()
getBall2()
getBall3()
getBall4()
getBall5()
}
PowerballLottery::WinningPossibility PowerballLottery::checkTicket( Powerba
llTicket ticket )
{
WinningPossibility result = WinningPossibility::NOTWINNING;
const;
const;
const;
const;
const;
#endif
//
//
//
//
//
//
//
Powerball.cpp
Project5
Created by Howard Stahl on 1/11/16.
Copyright 2016 Howard Stahl. All rights reserved.
#include "PowerballLottery.h"
#include "RandomNumber.h"
#include <iostream>
PowerballLottery::PowerballLottery( )
{
generateFiveBallPlusPB( mBall1, mBall2, mBall3, mBall4, mBall5, mPower
ball );
}
PowerballLottery::PowerballLottery( int ball1, int ball2, int ball3, int ball4, int b
all5, int powerball )
: mBall1( ball1 ), mBall2( ball2 ), mBall3( ball3 ), mBall4( ball4 ), mBall5( ball5
), mPowerball( powerball )
{
}
int PowerballLottery::getBall1() const
{
return( mBall1 );
}
int PowerballLottery::getBall2() const
{
return( mBall2 );
}
int PowerballLottery::getBall3() const
{
return( mBall3 );
}
result++;
}
if (isMatched(ticket.getBall4()))
{
result++;
}
if (isMatched(ticket.getBall5()))
{
result++;
}
return( result );
}
void PowerballLottery::printWhatHappened( PowerballTicket ticket )
{
using namespace std;
WinningPossibility possibility = checkTicket( ticket );
switch( possibility )
{
case PowerballLottery::POWERBALL:
cout << "You matched the powerball!" << endl;
break;
case PowerballLottery::ONEPLUSPOWERBALL:
cout << "You matched 1 ball plus the powerball!" << endl;
break;
case PowerballLottery::TWOPLUSPOWERBALL:
cout << "You matched 2 balls plus the powerball!" << endl;
break;
case PowerballLottery::THREE:
case PowerballLottery::THREEPLUSPOWERBALL:
cout << "You matched 3 balls";
if (possibility == PowerballLottery::THREEPLUSPOWERBALL)
{
cout << " plus the powerball!";
}
cout << endl;
break;
case PowerballLottery::FOUR:
case PowerballLottery::FOURPLUSPOWERBALL:
cout << "You matched 4 balls";
if (possibility == PowerballLottery::FOURPLUSPOWERBALL)
{
cout << " plus the powerball!";
}