0% found this document useful (0 votes)
551 views26 pages

Python Lottery Documentation

The document outlines tests for a Pick-3 Lottery game including: 1) Testing if the wrong password is accepted. 2) Testing what happens if three wrong passwords are entered. 3) Testing if the game redirects to the menu after the correct password. The document provides details on 10 test cases and results to ensure the game's functionality and security are working as intended.

Uploaded by

Ashesh Poudel
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
551 views26 pages

Python Lottery Documentation

The document outlines tests for a Pick-3 Lottery game including: 1) Testing if the wrong password is accepted. 2) Testing what happens if three wrong passwords are entered. 3) Testing if the game redirects to the menu after the correct password. The document provides details on 10 test cases and results to ensure the game's functionality and security are working as intended.

Uploaded by

Ashesh Poudel
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 26

Contents

Contents..................................................................................................................... 1
Table of Contents....................................................................................................... 3
Introduction................................................................................................................ 5
Objectives................................................................................................................... 6
Design........................................................................................................................ 6
Nature of the Solution................................................................................................ 6
Intended Benefits....................................................................................................... 9
Limits of the scope of the solution.............................................................................. 9
Testing........................................................................................................................ 9
1............................................................................................................................... 10
To test if the wrong password is accepted or not.....................................................10
2............................................................................................................................... 10
To test what happens if three wrong passwords are entered...................................10
3............................................................................................................................... 10
To test whether it redirects to menu after right password.......................................10
4............................................................................................................................... 10
To test what happens when invalid command is pressed in menu...........................10
5............................................................................................................................... 10
To test if valid commands respond what is has to respond......................................10
6............................................................................................................................... 10
To test if value less than 10 is accepted or not........................................................10
7............................................................................................................................... 10
To test if value greater than 99 is accepted or not...................................................10

8............................................................................................................................... 10
To test if same value is accepted or not...................................................................10
9............................................................................................................................... 10
To test if game report is shown while quitting the game..........................................10
10............................................................................................................................. 10
To test if user can go to menu after the game.........................................................10
To test if the wrong password is accepted or not.....................................................10
To test what happens when invalid command is pressed in menu...........................12
To test if valid commands respond what is has to respond......................................13
To test if value less than 10 is accepted or not........................................................14
To test if value greater than 99 is accepted or not...................................................14
To test if same value is accepted or not...................................................................15
To test if game report is shown while quitting the game..........................................15
To test if user can go to menu after the game.........................................................16
Test Log.................................................................................................................... 17
To test what happens if three wrong passwords are entered...................................17
To test if valid commands respond what is has to respond......................................18
To test if value less than 10 is accepted or not........................................................18
To test if value greater than 99 is accepted or not...................................................18
To test if same value is accepted or not...................................................................18
To test if game report is shown while quitting the game..........................................18
To test if user can go to menu after the game.........................................................18
Appendix.................................................................................................................. 18
Implementation of Security...................................................................................... 25
Reference:................................................................................................................ 26

Group C2

[Type the company address]

Pick-3 Lottery game


Ashesh Poudel

2012
Table of Contents
Contents..................................................................................................................... 1
Table of Contents....................................................................................................... 3
Introduction................................................................................................................ 5
Objectives................................................................................................................... 6
Design........................................................................................................................ 6

Nature of the Solution................................................................................................ 6


Intended Benefits....................................................................................................... 9
Limits of the scope of the solution.............................................................................. 9
Testing........................................................................................................................ 9
1............................................................................................................................... 10
To test if the wrong password is accepted or not.....................................................10
2............................................................................................................................... 10
To test what happens if three wrong passwords are entered...................................10
3............................................................................................................................... 10
To test whether it redirects to menu after right password.......................................10
4............................................................................................................................... 10
To test what happens when invalid command is pressed in menu...........................10
5............................................................................................................................... 10
To test if valid commands respond what is has to respond......................................10
6............................................................................................................................... 10
To test if value less than 10 is accepted or not........................................................10
7............................................................................................................................... 10
To test if value greater than 99 is accepted or not...................................................10
8............................................................................................................................... 10
To test if same value is accepted or not...................................................................10
9............................................................................................................................... 10
To test if game report is shown while quitting the game..........................................10
10............................................................................................................................. 10
To test if user can go to menu after the game.........................................................10
To test if the wrong password is accepted or not.....................................................10
To test what happens when invalid command is pressed in menu...........................12

To test if valid commands respond what is has to respond......................................13


To test if value less than 10 is accepted or not........................................................14
To test if value greater than 99 is accepted or not...................................................14
To test if same value is accepted or not...................................................................15
To test if game report is shown while quitting the game..........................................15
To test if user can go to menu after the game.........................................................16
Test Log.................................................................................................................... 17
To test what happens if three wrong passwords are entered...................................17
To test if valid commands respond what is has to respond......................................18
To test if value less than 10 is accepted or not........................................................18
To test if value greater than 99 is accepted or not...................................................18
To test if same value is accepted or not...................................................................18
To test if game report is shown while quitting the game..........................................18
To test if user can go to menu after the game.........................................................18
Appendix.................................................................................................................. 18
Implementation of Security...................................................................................... 25
Reference:................................................................................................................ 26

Introduction
Lottery game is a form of gambling which dates back to early 20th century.
The definitions of lottery are many, but the main definition is: A lottery is a
form of gambling which involves the drawing of lots for a prize. There are
many kinds of lottery games in the world. Some of them are: Lotto, Little
Lottos, The Dailies, Multi-state Games, Instant Games, Quick Picks and so on.
New types of lottery games are popping up more and more frequently. But
the basics remain Lotto, Little Lottos, Dailies, Multi-State Games, and Instant
Games. The Instant Games are scratch-off tickets, while the other lottery

games are on-line games because they consist of computer-generated


tickets. In this project, Dailies or pick-3 is done.

Objectives
The main objective of building this project is that the game will be played
more efficiently, fast and with comparably less error. The Lottery game
before was very traditional, client picked three numbers and a clerk picked
three numbers at random. That used to take lots of time as the clerk has to
think the random numbers from certain range of numbers. The pattern to
generate numbers by clerks is comparatively easy to guess then the
computer generated numbers. There might be mistake in calculating the
report of the user as well. By building this system, the game is fast, efficient,
easy and a lot hassle free. There wont be a clerk necessary for generating
random numbers or calculating the price. Everything will be computer
oriented as it will be efficient, fast and reliable.

Design
Design is all about preparing the ground work so that during the next stage,
coding, the only major decisions have to be made are about the coding itself.
I have choosen Pyhton 2.5.4 platform to make this system.

Nature of the Solution


When the user or someone starts the program the gets a page where
he has to enter a password, so that unauthorised person cannot access
the program.

After typing the correct password, a welcome screen with game menu
will appear like below:

When user selects the first option, i.e. (a), the following layout comes

When user selects (y) and (b) in main menu, game starts and the
layout is like:

After the game, if user selects to end the game,it exits showing all the
report of the player. It looks like:

Intended Benefits
There are many benefits of this system to be computerized.
The system for playing lottery is systematic.
The errors will be less.
Navigating through game is easier
It is a lot easy

Limits of the scope of the solution


The limit of the system is that the user has to have a little computer knowledge.
Currently the system cannot back up the data of the players. It has no Graphical
User Interface, which is very frustrating for some user. If someone finds about the
password then anyone can play this game.

Testing
Test Plan

1.

To test if the wrong password is accepted or not

2.

To test what happens if three wrong passwords are entered

3.

To test whether it redirects to menu after right password

4.

To test what happens when invalid command is pressed in menu

5.

To test if valid commands respond what is has to respond

6.

To test if value less than 10 is accepted or not

7.

To test if value greater than 99 is accepted or not

8.

To test if same value is accepted or not

9.

To test if game report is shown while quitting the game

10.

To test if user can go to menu after the game

Test case 1
Test Plan

To test if the wrong password is accepted or not

Test Data

Any key that is not the actual password

Expected
Result

Should ask user to input the password again

Actual Result

Prompt user to input the valid password

Concusion

Hence expected result and actual result matched

Test case 2

Test Plan

To test what happens if three wrong passwords are


entered

Test Data

Three wrong passwords

Expected
Result

Should notify user about the input of wrong password and exit

Actual Result

Prints user the information on why they are not able to enter and
exits

Conclusion

Hence expected result and actual result matched

Test case 3
Test Plan

To test whether it redirects to menu after right


password

Test Data

Correct password

Expected
Result

Should direct to the menu

Actual Result

Directs to the menu

Conclusion

Hence expected result and actual result matched

Test plan 4
Test Plan

To test what happens when invalid command is


pressed in menu

Test Data

Invalid command

Expected
Result

Should notify about invalid command and prompt user to input


valid command

Actual Result

Notice is given to user about invalid command and user can input
valid command

Conclusion

Hence expected result and actual result matched

Test plan 5

Test Plan

To test if valid commands respond what is has to


respond

Test Data

Valid command (a,b or c)

Expected
Result

Should direct user to specified place

Actual Result

Directs user to specific place

Conclusion

Hence expected result and actual result matched

Test Plan 6
Test Plan

To test if value less than 10 is accepted or not

Test Data

Value less than 10

Expected
Result

Should notify user about invalid input and prompt to enter again

Actual Result

Notifies user about invalid input and prompts to enter again

Conclusion

Hence expected result and actual result matched

Test Plan 7
Test Plan

To test if value greater than 99 is accepted or not

Test Data

Value more than 99

Expected
Result

Should notify user about invalid input and prompt to enter again

Actual Result

Notifies user about invalid input and prompts to enter again

Conclusion

Hence expected result and actual result matched

Test Plan 8
Test Plan

To test if same value is accepted or not

Test Data

Same value in two place

Expected
Result

Should not accept two same values and prompt again to enter the
different value

Actual Result

Notifies user about invalid input and prompts to enter again

Conclusion

Hence expected result and actual result matched

Test Plan 9
Test Plan

To test if game report is shown while quitting the


game

Test Data

Expected
Result

Should show the report of the user on quitting the game

Actual Result

Report of the user is shown when user selects to exit

Conclusion

Hence expected result and actual result matched

Test Plan 10
Test Plan

To test if user can go to menu after the game

Test Data

N/A

Expected
Result

Should go to menu after playing game

Actual Result

Goes to menu after playing game

Conclusion

Hence expected result and actual result matched

Test Log
S.
No.

Test Plan

Conclusion

1.

To test if the wrong password is accepted or not

Successful

2.

3.
4.

To test what happens if three wrong passwords are


entered
To test whether it redirects to menu after right
password
To test what happens when invalid command is

Successful

Successful
Successful

pressed in menu
5.

6.
7.
8.
9.
10.

To test if valid commands respond what is has to


respond
To test if value less than 10 is accepted or not
To test if value greater than 99 is accepted or not
To test if same value is accepted or not
To test if game report is shown while quitting the game
To test if user can go to menu after the game

Appendix
#Ashesh Poudel
#Sept, 2012

import random
import os, sys, time
import errno, sys
from random import randrange
from time import sleep

Successful

Successful
Successful
Successful
Successful
Successful

def dprint (message, delay=0.01):


"""
Prints message with delay between each character.
"""
for char in message:
sys.stdout.write(char)
sys.stdout.flush()
time.sleep(delay)
if __name__ == '__main__':

dprint('

__

' / _/_/_ _

\n' +

/ _ _ _ _\n' +

'(__()/ /(-/ (/ (__)(///)(-\n' +


'

')

print
print "Please enter your Password, carefully as 3 wrong passwords will close
the game."
def get_password():
# give it three tries
for k in range(3):
encoded = "cvpx3ybggreltnzr"
password = raw_input("Enter your password: ")
if password == encoded.encode('rot13'):
return True
return False

def start():
if get_password():
print ""
def dprint (message, delay=0.05):
"""
Prints message with delay between each character.
"""
for char in message:
sys.stdout.write(char)
sys.stdout.flush()
time.sleep(delay)
if __name__ == '__main__':
dprint( '__
'\ \

_____ _

___ ___ __ __ ___ \n' +

/ / __| | / __/ _ \| \/ | __| \n' +

' \ \/\/ /| _|| |_| (_| (_) | |\/| | _| \n' +


' \_/\_/ |___|____\___\___/|_| |_|___|')
print ""
dprint ('********PICK-3 Lottery System*********')
winningamt,total,winninggames,gamesplayed,gameswon,cmd,y=0,0,0,0,0,N
one,"n"
while cmd!="stop":
for i in range(2):
print""
print"MAIN MENU"
print"(a) Game Instructions"
1

print"(b) Lottery Game"


print"(c) Exit"
answer=raw_input("Press a, b or c and press Enter to continue: ")
for i in range(2):
print""
if answer=="a":
print "The user selects three disticnt numbers"
print "(each must be different) between 10 and 99 inclusive."
print "The user's number and the computer numbers are then
matched,"
print "giving a result of no matches, 1 match, 2 matches or 3
matches."
print "Each game costs student NRs. 100"
yn=raw_input("Do you want to play game? y/n").lower()
print""
if answer=="b" or answer=="a" and yn=="y":
#starts game here
while True:
try:
#trys the block of statements
print""
amount=int(float(raw_input("Enter the amount you want to
spend on game: "))*100)/100.00
print""
if amount%100!=0:
print"You can take Rs.",amount%100,"Home.",

amount=amount-amount%100
if amount>=100:
break
else:
print"Opss Invalid amount! Enter again!"
except ValueError:
print"Opss Invalid amount! Enter again!"
total=amount+total
while amount >=100:
print"Currently you have Rs.",amount,".You can
play",int(amount/100),"times with it!"
numbers,randomnumbers,numberscount=[],[],0
gamesplayed=gamesplayed+1
print""
while numberscount!=3:
#takes three distinct numbers from user, validate it and
stores in list
if numberscount==0:
prompt="Enter first number: "
elif numberscount==1:
prompt="Enter second number: "
else:
prompt="Enter third number: "
try:
number=int(raw_input(prompt))

if number>9 and number<100 and


numbers.count(number)==0:numbers.append(number);numberscount=
numberscount+1
else:
print"Invalid number! Enter again."
except ValueError:
print"Invalid input! Enter again."
for i in range(2):
print""
amount,numberscount=(amount-100),0
for x in range(3):randomnumbers.append(randrange(10,100))
numbers.sort()
#sorts the list in ascending order
print"Number you Entered are:",
for i in numbers:print i,
print
print"Computer Generated Numbers are:",
for i in randomnumbers:
#counts the matches
if numbers.count(i)>=1:numberscount=numberscount+1
sleep(1)
print i,
print
sleep(1)

if
numberscount==2:winningamt=winningamt+93;print"Congratulations! 2
matches. You win Rs.100.";gameswon=gameswon+1
elif
numberscount==3:winningamt=winningamt+0.93*1500;print"Congratulatio
ns! 3 matches. You win Rs. 1500.";gameswon=gameswon+1
else:
print"Sorry!",numberscount,"Matches. Better luck next
time."
raw_input("Press Enter...")
print""
elif answer=="c":
print "Do you really want to Exit the game?"
y=raw_input("Press y for Yes and any key for No: ").lower()
print ""
if y=="y":print"Game Exits now...";command="stop"
#exit game
if answer!="c" and answer!="a" and answer!="b":
print"Select Valid Command."
if y=="y":
#shows report of player
if gamesplayed!=0:
for i in range(2):print""
print"Your Game Report is:"
print"You played :",gamesplayed,"games."
print"You won :",gameswon,"games."
print"You lost :",gamesplayed-gameswon,"games."

print"You won :Rs.", winningamt,"(inc 7% TAX)"


print"Your win percentage
is :",gameswon/gamesplayed*100.00,"%."
print"Your net balance is :Rs.",winningamt-total
else:
print"Dude u dint play any games! So now no game report!"
raw_input("Press enter")
print "THANK YOU FOR PLAYING!"
break
sys.exit(errno.EACCES)

else:
print "Wrong password!"
print
print "The game will now End"
sys.exit(errno.EACCES)

if __name__ == "__main__":
start()

Implementation of Security
For security the system has a password system. The password is given to the
system administrator. It administrator wishes to change the password, it will
be changed. The password code in the system coding is encrypted which
helps in security. For example is someone has access to the coding itself,

s/he cannot obtain the password from coding. Though it is not impossible but
without much computer knowledge, it is very hard to obtain password.

Reference:
ASCII art, accessed September 25, 2012,
<http://www.kammerl.de/ascii/AsciiSignature.php >
Types of Lottery, accessed September 26, 2012,
<http://tlc.howstuffworks.com/family/how-to-play-the-lottery1.htm>

You might also like