Python Lottery Documentation
Python Lottery Documentation
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
2012
Table of Contents
Contents..................................................................................................................... 1
Table of Contents....................................................................................................... 3
Introduction................................................................................................................ 5
Objectives................................................................................................................... 6
Design........................................................................................................................ 6
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
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.
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
Testing
Test Plan
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
Test case 1
Test Plan
Test Data
Expected
Result
Actual Result
Concusion
Test case 2
Test Plan
Test Data
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
Test case 3
Test Plan
Test Data
Correct password
Expected
Result
Actual Result
Conclusion
Test plan 4
Test Plan
Test Data
Invalid command
Expected
Result
Actual Result
Notice is given to user about invalid command and user can input
valid command
Conclusion
Test plan 5
Test Plan
Test Data
Expected
Result
Actual Result
Conclusion
Test Plan 6
Test Plan
Test Data
Expected
Result
Should notify user about invalid input and prompt to enter again
Actual Result
Conclusion
Test Plan 7
Test Plan
Test Data
Expected
Result
Should notify user about invalid input and prompt to enter again
Actual Result
Conclusion
Test Plan 8
Test Plan
Test Data
Expected
Result
Should not accept two same values and prompt again to enter the
different value
Actual Result
Conclusion
Test Plan 9
Test Plan
Test Data
Expected
Result
Actual Result
Conclusion
Test Plan 10
Test Plan
Test Data
N/A
Expected
Result
Actual Result
Conclusion
Test Log
S.
No.
Test Plan
Conclusion
1.
Successful
2.
3.
4.
Successful
Successful
Successful
pressed in menu
5.
6.
7.
8.
9.
10.
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
dprint('
__
' / _/_/_ _
\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( '__
'\ \
_____ _
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
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."
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>