diff --git a/.gitignore b/.gitignore index 53c83987d..3393122bb 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ local.properties .settings/ .loadpath .recommenders +*.DS_Store # External tool builders .externalToolBuilders/ diff --git a/ASCII of instructors b/ASCII of instructors new file mode 100644 index 000000000..a5665c597 --- /dev/null +++ b/ASCII of instructors @@ -0,0 +1,312 @@ +Roberto + +****************************(%%%%%&&&&&&&%(//******************************,*** +***********************/(%&&&@&@&&&&@@&&&&@&&&&@(****************************** +*//**************,*(%&&&&&@&&&&@&&&&&@@@@@@@@@@@&&%@&/***********************,* +(/*/***********/%&&&&@&&&&&&&&@@@@@@@@@@@@@@@@@@@@@&@@@@%********************** +*/(//********#&&&@@&@@&&&&&&%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%******************* +****(/*****/&&&@&&@&@&&&@@@@@&&%%%%%&&%%%%%%%&&&&&@&@@@@@@@@@(***************** +******(///(&&&&&@@&&&&&%%#((/////////*******////((###%&@@@@@@@#**************** +*******/((&&@@&&&&&%%(//*************************////((%&@@@@@@#*************** +*********%&&@@@#(/***,,,,,,,,,,,,,,,****************//(#&@@@@@&/************* +********#%&@&&(/***,,,,,,,,,,,,,,,,,,,,,,,*,,************/(%@@@@@@&************ +*//****(&&&&%(*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*********//#&@@@@@@%*********** +///***/&&@&%(/*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,**********/(%@@@@@@@/******,*** +//////%&@&%#/*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*********/(#&&@@@@@&********** +/////(@&&(*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*********//#%&&@@@@@/********* +/////#&&%#(/,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,**********/(%%&%@@@@%********* +/////&&(/*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*********//(#%&&&@@@/******** +**///%%%((/*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*********////(##&&@@@#******** +****(%%#((*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*************//////(#%&&&@%*/****** +****(%###/*,,,,,*///(%%#####(*,,....,..,,,/(###%%%%%#//(////////#%%&&@&******** +****(%###*,,,*//(((#(((/////***,,,.,,,,,,**//////(((#((((##(////(%%&&@%******** +/*//(%##(*,,//**//**********,,,,,,,,,,,,*****/*******//(((#%(///(%%&&&%******** +****(%##(,,*/**,,,,,,**********,,,,,,,***///////////**//////((///%&&@&%/////*** +****(%##/,,*,,,,,,*******//(//**,,,,,,*////(((/((%#(//((/////////#&&&%////(///* +****/#%#/,,,,,**/**#&@@%@%((///**,,,,**////(#(*&&(@&(#&(//*////(&@#////**/*** +***,,/%%*,,,,,**(#(((###(/((((***,,,,**/////////////**/////***///(%&//********* +(***,,(%**,,,,,**,,,,,,,********,,,,***/////**////*************//(#&(//******** +/**,,*/#**,,,,,,,*****/****,,,,,,,,,,**/*//********************/(/#&/*,,,,*/*** +*/,,,,#(**,,,,,,,,,***,,,,,,,,,,,,,,,*///********,****,,,*****//((#&(*,,,**/*** +/*,,,,((**,,,,,,,,,,,,,,,,,,,,,,,,,,,,*///*****,*,,,,,,,,*****///((&/***/*/**** +**,*,,/#*,,,,,,,,,,,,,,,,,,,,**,,,,,,,,**/////*,,,,,,,,,,,***////((*//*/***** +//,**,/#*,,,,,,,,,,,,,,,,***,,,,,,,..,,******//**,,,,,,,,,***////(#@%//***/**** +*/****(%*,,,,,,,,,,,,,,*****,,,,,,,,***//(/////*******,,****/////(#@&/****(**** +***,,,/%/***,,,,*,,,****,,,**//*****/((///(((//************////((#&@&////(/**** +/*/,,,(%(*****,****/*****///(#%%%#/////##&&%%###(#((((((///////((%&@(##(***** +/*/(,,(&%*********(#####%&%&&&%%%%&%%%&%&&&&@@&&&&&&&&%%#/////((#&@@&&%#/****** +***(#(#&&(*******(#%%%%%%%%%&%%%%%%&&&%&%&&@&%&&&&&&&&((/((#%&@@&((((/////* +****/(#%%%(*****(%%&&&&&&&&&&%%&%((#(#%#%%##%##%&&&@@@@&((((#%&&@@&((((////// +****//(%&%%(**//#%%&&&&&(####(//***,,*...,,/((##((#&&&&&%%##(#%&&@&@%/((((///// +*****/(&&&%#(//#%%%&&&(////*****/****/////(((//((%&&@&&&&%&&@@@@%///((((/(( +*****//%&&&%%###%%%&&&%%#(///*****/******//(////((#%@&&&&&&&%%&@@@@@#/*///((((/ +*//**//#&@&&%%&%%%&&@@&%%((/((/((((#(((######(###%%%&@&@@@@&@&&@@@@@#/***/*/((( +****/*/%&@@@&&&&@@&&@@&&%%%%&%%&%%&&&@@@@@%%%%&&%%&&@@@@@@@@@@@@@@@&(/*****/*(( +****///#%@@@@&@&@@@@@@@&&&&&&&&&&@@@@&@@&&%%%@@@&@@@@@@@@@@@@@@@@@&%/********// +***/**/(#&&@@@@@@@@@@@@@@@&&&&&&&&@@@&@&&%&&&&&@@@&@@@@@@@@@@@@@@@%(*********** +/*/***//(%%@@@@@@@@@@@@@&@@@&&&&%##%%&&%&%(&&&@&@@@@@@@@@@@@@@@@@%(/*//******** +****/***/#%&&@@@@@@@@@@@@@@&&&&&&%%#%%&&&%@&&&@&@@@@@@@@@@@@@(//*****////** +*/*//***//#&@@@@@@&&@@@@@@@@@&&@%&%%#%#&%%&&&&@@@@&@@@@@@@@@@@@%((//****///***/ +/*****//**#&&&&&&&@@@@@@@&@@&&&&&&@&@&&&@&&@@@&@@@@@@@@@@@@@@@&(((**/////***//* +////******(#%%&@@@@&@@@@@@@@&&@@@@@@@@@@@@&@@@@@@@@@@@@@@@@@@%(//(%@@@#/***//** +*******///*(#*#@@@@@@@@@@@&@@&@@@@@@@@@&@@@@@@@@@@@@@@@@@@@@%(///((((//&@#///*/ +**/***/&@@@&*,,*/&&@@@@@@@&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&(//*///(////(&@@@@@% +//#&@@@@@@@/*,,,,/(%@@@@@@@@@@@@&@@@@@@@@@@@@@@@@@@@@@@@&%(/***///(//*/(@@@@@@@ +@@@@@@@@@@@/*,,,,,,,/#&&&@@@&@@@@@@@@@@@@@@@@@@@@@@@@&%(********///(/**#@@@@@@@ +@@@@@@@@@@@/*,,,,.,,,,/(((#&&@@@@@@@@@@@@@@@@@@@@@@%(/**********/////*/@@@@@@@@ +@@@@@@@@@@@%*,,,,,,..,,,,,**(#%%%%&&@@@@@@@&%&&%(*************//////&@@@@@@@@ +@@@@@@@@@@@@/,,,,,...,..,,,,,******(%&&@&%%#/(///*****,***********/**@@@@@@@@@@ +@@@@@@@@@@@@@/,...........,,,,,,,***(((((//*********,,*************/@@@@@@@@@@@ +@@@@@@@@@@@@@@#,,.......,,,,.,,,,,,****************,,,,***********%@@@@@@@@@@@@ +@@@@@@@@@@@@@@@@*,.......,,,,,,,,,,,,,,,,**,*******,,,,,,,*****,(@@@@@@@@@@@@@@ +@@@@@@@@@@@@@@@@@&*,,.,,,,,,,,,,,,,,,,,,,********,*,,,,,,,,,,,*&@@@@@@@@@@@@@@@ +@@@@@@@@@@@@@@@@@@@&*,,,,,,,,,,,,,,,,,,*********,,,,,,,,,,,,*%@@@@@@@@@@@@@@@@@ +@@@@@@@@@@@@@@@@@@@@@@#*,,,,,,,,,,,,,,,,,,,****,,,,,,,,,,,/&@@@@@@@@@@@@@@@@@@@ +@@@@@@@@@@@@@@@@@@@@@@@@@#/*,,,,,,,,,,,,**,,,,,,,,,,,,,*%@@@@@@@@@@@@@@@@@@@@@@ +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%(****************,,,,/#@@@@@@@@@@@@@@@@@@@@@@@@@@ +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&&%####%%%&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + + +Kris + ... ,,.......** .*,,**///*,.. ..,,,,,.,,,***//***, ....... .... .,,..,,. ,,**,,,*. + ....,,...***,,,,**,,,,...,. ,,....... . ..,,,........**, .,..,... + ..... .,**..,,*******,,,. .. . ..,.. ...... .. ., + ,,. .,**.,*,,,..,, .. ... ...,,..,***,..,,..,........... + .,,,*******,,,**, ....... ........ ... .,**,*.....***,.,**. ,*,,.... + .,.,...,,...,. ..............,,,,,,,,.... .,/*..,,*/(/,,**,*/**..,****..,. . + ........ ............................... .,//,. */(/,,*,,,,,,,.,,***,.... + .,,,*, . .. ...... ......,,.............,,,,,,.. .,,,,,.***/* ,*,..,,..,,*,,,,,.... + ...,,,**,, .... ............,,,,,,,,,,,*******,,,,,,,. ,*,,///(/*,. ...,,,,.,*/***,,...,,...,, + ,,***,.... ...............,,,,,,,,,,,,***********,,,,,,,,. ,*((//(/*,, .. *///////*,,,,,*,.,,. + ..**,******. .......,,,,,,,,******,,,,******////****,,,,,..,... .*((**//*//****,,,,***(((/**,*******,..,... + .,**,.,**** ....,,,,****************//////////*********,,,,.,.. .//////(((/*,,**,,*((//(////(/**,/*,***,.. + .,,*,,**,. ..,***********/////////((((//////***********,,,.,,.. ,,,,,*////*** .*/(/**///*/((/*///**//*,,, + ,,,,,,*. ..,**********///////////////////////////*******,,,,,.. .,*...**(/.,.. .,*/////,,/((/////***,,.. + ...,,,,,. ...,*///********///////////////((////////*********,,,.. ...,///,,..,...,/(/////(/**//(/*,. . + ...,**.. ..,**//******//////////////////////////***********,,,,. ,,.,..*((//**..,,.,*((((**(/,,,,*,... +,. . ...,,,, .,,**/*****/////////////////////////************,,,,,,,.. ,,,,,.,*/#(**,*,.. ,*/*,,,,. ..,,.. +**,.,, .... .,,********////////////////////////*************,,,,,,.,.. .,*//..**,,,,.,,....... . ....,,*/,. +/*,,..... .,,,,, ..,********///////////////***//////////*********,,,,,,,... ..,,,,.,*...,*,. .....,,. ,,,,,*//.. +*//***...,,,,,***,. ..,,,*****////////////*******///////(/////(///////**,..... ,* .. .,*,**.,*..,,,**,*..****,.,* +,*//..*,. .,***,... ..,,,*****///////////*////////((((((((##########(((//*,... .*, .. .,*. ....*,..*//,,*****,,, +,,,,..**,,,,,,,..** ..,,,*****//*//////////((((((((#######%%%%%#######((##/*...**,**, .. ,..,,**//*//***,. .,*/ +.. .,,**,..,***, ....,********/**///((((############%%%%%&&&&&&&%%%%%#(/*,..,*,,//***,...... .,.......... ,*// + . .. . ...,***,,,. ....,,,*******////((################%&&&&&&%%%%##(((/******.,**,..*//*,**,. .,,*, ..,.,*. ,/ +*/(/,,.,*,,. ,**,,**,. ...,,******//(((#####%%%%&&%#((//(#%%%%%%%######(********,.,,*//****//*,,,..,** ......,,,,.., +,*//.. .,//**,,*,,,,......,,******///((##&&&&&&&&&%%((////((########(//**********,.,,//**/*//,,,,.,*..,,,,,..,***,*//. +,***,,.... ..,*..,,,***,,,,,***////(%%%%%%%%%%%%%##((/////((((((((////////******,...,*****,.,,,..,..,*/(/**,,.,*,.,,,* + .//*/,. .,. .. ..,*((,,****/(###(((((###%%###(((//****//((###(((///((((//****,.,,. *(/*,.. .*/**((*,,,.,,,, ... +*,... .,,, ./(,,,,**/////((######(((((/////**,***////#%%%#######((/**/*,. ...***,,. ,//*/(/*,. ..,...,, +,,*,..... .... ....,/**,,****////////////(((((((//**********/(&&%%%%%####((///*,. ...,,*//**,,*/(///*,,*,***//* +*,..,, .. .. ,, ....,*/(,,**//////////////(((#(/////////////((#%%%%%%%%%###(////*.. .. ,///**/(///,,,*//,**, +..,, . .,.. .....*//**..//*,***///////////(((#%%(/////((####%%%%%%%%%%%%%%####(((//,.. .,. ... .*/*,//(((////##(*.. +(/.. ,,.,//* ..,*/*******,,****///////(((##%%%%#(((#######%%%%%###%%%%&%%######((/,.,..,*//,..,/,,*//*,*/(((##(((/*, +((*/*,*/*,*/*,,.,*/*,,*/((***********//((((##%%%%%###%%%%%%%%%%%###%%&&&&&%%#######((*,....***,. ..,**////**/,,**/(/**/ +%%####**/(/((/***///((#####/******/***/((###%%%%%#########%%%%%%%%%%%@@&&########((,.***,,,... ,,**(((#(//*,.******, +(#%#((((((((((//(%########%&(****///**/((##%%%%%##((########%#######%&%%%%##(((####(/*, .,..... .,*/***,.*/,.... +###(//(///((//*/(#((((######(//**///////(##%%%&&&&&&%#(#(((((((###%%##########(####(/((. +%%#(((//**(#(((((/*/((//(((((#(/**/////(((##%%&&&&&&&%#(#####%###(((((##(((###(###(//#%, +%%((((//*.*//...,/*,,(####/,/(#(***////((((###%%%%##(((((((((####(((((((((((######(//%&*. ... +###(((///,.***,,..,....,/##(/(%%(/**//(((((((#%%##((((((((#######((((((((///((##((/(#&&*..... +#(////,. .. ....., .,((##%%%%***//((((((####(((((((((((((((((((((((////((#((((#%&&*. .. .... +,,,***.. .,, .***,...,/##%%%%(/**///(((((##((((((((((((((//////////////((((((#%&&%*. .. .... +,,(((/,...,,,*, ..,***///((((##%%#*,**//(((((((((((((///(((////////////////(#((((%&&,. ........ +..*, ...,*/*,,,..,***. */**(###, ,*////(((((((/////(((((//(((//////((((((#(((#&&&,. ................ + ...,,.,,, .*//,***..,*/(/.. .,. ..*////((((((//////(((((((((((#######(######%&&((#(*...,.................. +*,..*///,,***,,***,.,,,,**//. ..,//////(((((//////((((((#################%%&&/(#(*.,,,...,,,............. +,. .,*//((/,,..******,,,.. ......,/#(//////((((//(((((##################%%%&%#(/*/,,,,,,,....................... +,,......*/..*##(/,*/*,,, ..,..,,(%#(//////(((((((((################%%&(((/,,,,,,,,,.....................,, +****,,..//,*(#(####/, ..............,*#%%#((((((((((((#################%%(((/**,****,,...................,,,** +(**(#(../(##%%#%%, ..... ....,,...,,*#%&%#(((((((((((((((#########%%&(((/*******,,.................,,****** +%%%#%%##//#%%#(. ...................,,,.,,,**#%&&%%##(((((###########%%&&&&(////******,,................,,****//// +#%%%#######/* .............,,,,,.....,,*,.,,*((#%&&&&&%%%%%%##%%%%%%&&&&&%#//***////*,,...............,,,********* +%%%##%%%#(. . ........,,,,,,,,,,,,***(%&%#(//#%&&&&&&&&&&&&&&&&&&&&(//**////**,,............,,,,,,,,,,,,,,,, +##%#%&%(. ................,,,,,,*****/(%&&%(/**/((#%&&&&&&&&&&&&&%(/**/////*,,,........,,,,,,,,,,,.......... +(/(%&%*. ..............,,,,,,****/((%%%%((/////(#####%%%&&&&(/*/((///*,,,,,,,,,,,,,,,,*******,,........ +((((*. ......... .........,,,,,,***////(###############(((#%#/*/(((//*****************************,,.... +##/, ......,,,,,..................,,,,,***////(((((((((#########//////((/////////////////////////////////**** +/* ...........,,,,,,,,,,.............,,,,***////////////////(((/**////((///////////////////////////////////// +. ................,,,,,,,,,,,,,,,,,,,,,,,,,,,********//////////////*//////////////***********************////// + +Chris +(((((////////////////////////////////////***********************////////*. .................................... +((((//////////////////////////////////***********************************. .............................. +####((((((/////////////////////////**************************************. .................. +(((((((((((((((((((////////////////**************************************. .,,,... .......... +///////////////////////////////////////////****************************** .,**//(((((((//**,,... +///////////////////////////////////////////////////////*********////*****. .......,,,,,,***//((((((//*,,,.. +/////////////////////////////****************/////////////((/////////////*.. ....................,,,,***//((((((// +////////////////////////***************************/(((((////******************. ..............................,,,,,,, +/////////////////////***************************/((#((((///////****,,,,,,.,,,***/*,............................,,,,,,,, +/////////////////////*************************(##((((///////////***,,,........,,,***,......................,...,,,,,,,, +//////////////////////**********************(##((((((////////////**,,............,,***..........................,,,,,,, +((((((((((//////////////******************/###(((((((////////////**,,,,.............,,**,,,,,,,,..........,,,,,,,,,,,,, +///////////////////////////////////////*/(#########((((//////////***,,,,,.....,,.....,,**,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +///////////////////*********////////////%%%##########((((((/////***,,,,,,,,,,,,,,,,,,,,,*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +/////////////////**********************#%%%%##%%%####(((((((/////**,,,,,,,,,,,,,,,,,,,,,***,,,,,,,,,,,,,,,,,,,,,,,,,,,* +//////////////************************(%%%%%%%%%%#%##((((////////**,,,,,,,,,,,,,,,,,,,,****,.,,,,,,,,,,,,,,,,,,,,,,,*** +//////////////***********************(%%%%%%%########(((#%&&&%%#((//**,,,,,,,,,,,,,,,,,,****......,,,,,,,,,,,,,,,,,,,,, +/////////////************************#&&&&&%%########%%&&&&%%%%&&&%#(/***,,,*,,,.,,..,,,,***..............,,,,,,,,,,,,, +///////////////*********************/%&&&&&%%%#####%%&((//////(%%%%%#((/*****,,,,,,.,,,***,.......................... +///////////////////*****************(&&@@@@&&%%####%%######((((/((###(((((/*******,**,,,,****.. +(((((((///////////////////////****//(%&&&&&%%%###%%&&&&&&(((//((((###((//******/((#######(/,...... +/////////////////////////////////(&&&((&&&%%##((((((#%%&&%%%%%#####(((((((////////(((#%%##%%%(........... .. +/////////////////***************/####%%&&%%#(((///////((#(####(#((##((///**/***/((####((//*/(#,........................ +////////////***/***************/(((((#%&%%##((//////***//***////////**,,,*//,,,/#%(##((((/////......................... +////////////*******************/(((/#%%&%%##((/////*******,,,,,,,,,,...,*((*..,*#((#%%#((((*,,**,,,,,,,,,,,,,,,,,,,,,,. +//////////////******************/(////(%%###((////*********//*,,....,,,,*/*,,..,/,.**//////*..,,,/*,,,,,*************** +//////////////*//***************//(//(#&%%%#(((/////****,,,....,,*//(((*,*,,..........,,***,,,,**((*,,,**************** +////////////////*****************(/((#%&%%%##((/////****,,,,......,*//*,,,*,......,.......,,,,*,****,,,*********,,,**** +/////////////////***************/&%#(%&&&%%%##(((/////*****,,,,,,,,/((///((//****,,***,....,//******,,,**************,, +((((////////////////////////////#&&&&@@&&&&%%##((((///////*****,,,,*(#%%%&@##(%%(*,,...,,,***,,**,,,,,*************** +////////////////////**********/#%%%%&@@&&&&&%%###(((/////////****,,,**/(####%%%%%%(,,,......,******,,,,,*************** +//////////////////***********/%@@%%%%@@&&&&&%%####(((((///////((((((((###%%#(#%#(*,,,,,,,,,,,,*****,,,,,,**********,,,, +/////////////////**********/%&@@@@%%%@@&&&&&&&%%%###((((///###&&&%%#(////****///##(*,,*****,,,,,,,,,,,,,,,,,,,,,,,,,,,, +/////////////////********/(&@@@@@@&%%@@@&&&&&&&%%####((///(#%%&&&&%%%%%##((/////*/###(/*/*****,,,,,,,,,,,,,,,,,,,,,,,,, +/////////////////*******/%&@@@@@@@@@&@@@@&&&&&&&&%%%##((///###(((////**,,,*/(((#((#&%#(////***,,,,,,,,,,,************** +//////////////////////*/#&&@@@@@@@@@@@@@@@@@@&&&&%%%%%%#####(/**///(((/***,,,..,/#&&&%((////*******,,,,,,************** +///////////////////////(%&&@@@@@@@@@@@@@@@@@@@@&&&&&&&&%%%%%#///**///((##%##(/****/#%#////((*************/***////////// +////////////////////%&&@@&&@@@@@@@@@@@@@@@@@@@@@@@&&&&&%%%&%%#/////*/////((((((/***(#(((###(((((####((########%%%%##### +(((((((/////////(#%&&@@@@&&&&@@@@@@@@@@@@@@@@@@@@@@@@&&&&&&&&%%#(///*************//#####%%%%%%%%%&&&%%%%%&&&&&&@&&%%%%% +//////////////%&&&&&&&@@@&&&&&&&@@@@@@@@@@@@@@@@@@@@@@@@@&&&&%%%#(((////*/******//##%%%%((((((((#%&&%%%%%&&&&&&&&%#(/// +///////////(#&&&&@@@&&&@@&&&&&&&@@@@@@@@@@@@@@@@@@@@@@@@@@&&&%%%%%####(((((////(##%%%%(/////////(%&&%%%%%&&&&&&&&(((( +////////(%&&&&@&&&&&@@@@@@&&&&&&&@@@@@@@@@@@@@@@@@@@@@@@@@@@@&&&&%%%%%%%%###(#%%%%%#(///////////(%&&%%%%%&&&&&&&&&%(((# +/////(#&&&&@@@@&&&&&&&&@@@&&&&&&&&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&&&&&&&&&&&&&&&&%(,**///////////(%&&&%%%%&&&&&&&&&%#### +//((&&&&&&@@@@@@&&&&&&&&&@@&&&&&&&&&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&&&/ */((((#######%%&&%%#######%%&&%#(((( +%&@@@@&&&&&&&&&&&&&&&&&&&@@&&&&&&&&&&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&&&%&%/////****/((#%%%%%#((((((((##%%%#((## +@@@@@@&&&&&&&&&&&&&&&&@@@@@&&&&&&&&&&&&&@@@@@@@@&@@@@@@@@@@@@@@@@@@@@@@@@@&&&@@&%%&&%(/////(####%%%&%######%#%%&&&%%%%% +@@@@@@&&&&&&&&&&&&&&&&@@@@@&&&&&&&&&&&&&&@@@@@@@@&&&@@@@@@@@@@@@@@@@@@@&&&&&&&@@@@&%%@&%%%%%%%%%%%&&%%###%%%%%%&&&%%%&& +@@@@@@@@&&&&&&&&&&&&&&&&&@@@&&&&&&&&&&&&&&@@@@@@@@&&&&&&&&@@@@@@@@&&&&@&&@&&&&&@@@@@@&@&%########%%%#########%%%&&%%%%& +@@@@@@@@&&&&&&&&&&&&&&&&&&&@@@&&&&&&&&&&&&&@@@@@@@@@&&&&&&&&&%%%%%%%@@@%&@&&&&&@@&@@@@@&&%#((((((##%#(((((#####%&&%#%%% +@@@&@@@&&&&@@@&&&@@&&&&&&&&&@@&&&&&&&&&&&&&&&@@@@@@&&&&&%%%%%%%%%%%&@@##%@@@&&&&@@&&&&@@@&&&%%%%%%%%%%###%%%%%%%&&%%%%% +@@@@@@&&&&&&&@@&@@@&&&&&&&&&@@&&&&&&&&&&&&&&&&@@@@@@&&%&&%%%%%%%%%%######&@@&&&&&@&&&&&&&&&&%%%%%%%&%%####%%%%%&&&&&&&& +@@@@@&@@@&&&&&&&&@@@&&&&&&@@@@@&&&&&&&&&&&&&&&@@@@@@@&&%&&&%%%%#######(%#%@@@&&&&&@&&&&%%&&&%%%%%%%&%####%%%%%&&@@@@@@@ +@@@@@&&&&&&&&@&&&&&@@@&&&&&@@@@&&&&&&&&&&&&&&&&&&&@@@@&&%%%%%%%%%%###((###&@@@&&&&&&%%&&&&%%&&%&%%%&%%%%%%%%%%%%&&%%%%% +@@@@@@@@&&&@@&&&&&&&@@@&&&&@@@@&&&&&&&&&@@@@@@@@@@&&@@@&&%######((((((((###&@@@&&&&@&%%&&&&&%%%&%%%%##((((###(((((((((( +@@@@@&@@@&@&&&&&&&&&&&@@&&&@@@@@@@@@@@@@@@@@@@@@@@@@@@@&&%#%#%%%####(((((###@@@&&&&&&%%%&&&&&&%%%%#(((///(((((((((((((( +@@@@@@@@@@&&&&&&&&&&&&&&@&&&@@@@@@@@&&&@@@@@&@@@@@@@&&&&@&%#%%######(((((####@@@&&&&&&%%&&&&&&&&%%%((////(((((((((((((( +@@@@@@@@@@@@@&&&&&&&&&&&&&&&&&&&&@@@@&&&@@@@&&@@@@@@&&&&&@#%%#####((((((###&@@@&&&&&&%%&&&&&&&&&((///(((((((((((((( +@@@@@@@@@&@@@@@@&&&&&&&&&&&&&&&&&&&@@&&&&&@@@@&@@@@@@&&&&&@&%#%%#####(((((####&@@@&&&&&%%&&&&&&%&&&%((((((((((((((((((( +@@@@@@@@@@@@@@@@@@@@&&&&&&&&&&&&&&&&&@@&&&&@@@@&@@&&@&&&&&&&&%%%%%###(((((#####&@@@&&&&&%%&&&&&&&&&(((((((((((((((### + +Dolio +////////****////////////(////////////////////////////(/#%&@&&&&&&&&&&&&&&@&&&&%&%(//////////////////(((((////////////// +////////****////////////(//////////////////////////(##&&&&&&&&&&&&&&&@@@&&&@&@@@&&%/////////////////(((((////////////// +////////****//////////////////////////////////////#%&&&&&&&&&&&&&&@&&&&@@@@@@@@@&&&(//////////////(((((////////////// +////////****//////////////////////////////////(#&&&&&&@&&&&&&&&&&&&&&&&&@@&&@&&&@@&@&&%#//////((((/((((((////////////// +////////****////////////////////////////////(#&&&&&&&&&&&%%%%%%%%%%%&&&&&%&&%%&&&@@@@&@&%%%(///////((((((////////////// +////////****////////////(//////////////////#&&&&&&&&%%%############%%%%%%%%%%%%%%%%&&&@@&&#(/////(((((/////////////// +////////****///////////((/////////////////#&&%#%&&%###(((#((######%%%%%%%%%%%%%%%%%%%%&&@@@&%#/(//((((((/////////////// +////////****//////////(//////////////////(%#########(((((((((#####%%%%%%%%%%%%%%%%%%%%%%&&@@%%(///((((((/////////////// +////////****//////////(((////////////////#%#######((((((#((((#####%%%%%%%%%%%%%%%%%%%%##%%&@&%#((/((((((/////////////// +////////****//////////(/////////////////(%##%####((((((((((#######%%%%%%%%%%%%%%%%%%%%####%%&&%((/((((((//////////////* +////////****////////////(///////////////####(((((((((((((((#####%%%%%%%%%%%%%%%%%%%%%%%#####%&/((((((///////////////* +////////**,*/(///////*//////////////////##((((/((((((((((((#####%%%%%%%%%%%%%%%%%%%%%####%###&&%(((((((///////////////* +////////**,*/(/**//,////(//////////////((//(/(/////((((((#######%%%%%%%%%%%%%%%%%%%%%%########(((((////////////////** +////////*,,*//**//*///(////////////////(///////////((((#########%#%%%%%%%%%%%%%%%%%#%#########%#(((((////////////////** +////////*,,*/(*///////////////////////(/*//*////////(((########%#%%%%%%%%%%%%%%%%%%###########%#((((((((/////////////** +////////*,,*/(/////////(((/////////////**/**/***/////(((#########%%%%%%%%%%%%%%%%%%#############/(((((((////////////*** +//////***,,,*/*****/////*/*//****//////***///**///////########%%%%%%%%%%%%%%%%%%%%#############%((((((//////////////*** +////////*,,*/(////////((///////////////***///**/**//((##%%%%%%%%%%%%%%%%%%%%%%%%%############%#%(((((///////////////*** +////////*,,*/(///////(((/////////////(***////********/(#%%&&&@&&&%%%%%%%%%%%%%%#%###########%#%#/((((///////////////*** +////////*,,*/(///////((((////////*(###*//*//**********(##%%%&&&&&&&&&%%%%%%%%%%%%%############%(////(/((////////////*** +////////*,,*/(///////(((((///////%#*/////**********((##%%%%%&&&&&&&&&&&%%%%%%%%%%%###(########%(/((////////////////**** +////////*,,*/(////////((((//////#%*/(**/**/////(((#%%#(%@@@&%&@&&&&%&&&%%%%%%%%%%&&&&%%%%%%%%%(((((((//////////////**** +////////*,,*/////////(((((//////#*/((/****///((((((//#&&@@&%%&@&&&&%%%%%%%%%%%&&&&&&&@&&%%##%(//(((((/(////////////**** +////////*,,*/(///////(((((//////((%%%%*****//(((((((/(#%%%&&%&@@@@&%##%%%%#%%%&&&&&&&&%%###%%(//(((((//////////////**** +////////*,,*/(////////((((//////#(%%%*******///((#%%%%%%&&&@@@@@&&%#((#%%##%%&@@@@@&&&%&%####//(((((///////////////**** +////////*,,*/(///////(((((/////*#/#%/********//((#%%&&&&&&&&&&%%%%#(((#%%##%%&&@@@@@@&%&%&%%(//((((((/////////////***** +////////*,,*/(//////(((((///////(%*(%/*******///((%%%%&&%&%%&%%###(((##%%###%&&@@&&&&%%&&&%#(///((((((/////////////**** +////////*,,*/(////////((((//////*/************///(###%%%%%&&%%#(((((##%%%####%%&@&&&%###%%%#///((((((////////////****** +////////*,,*/(////////((((//////**(//**********//(#(##%%%%&%%%((((((##%%%####%%%%%&%%%%%%%%(///((/(((////////////****** +////////*,,*/(////////((((//////(/**/***********/(((##%%%&&&%(/**//(#%%%######%%%%%%%%%##%#//////////////////////****** +////////*,,*/(///////(((((/////#&%&%/***********//((##%&&&%%(/(%@@&((#%%#(((##############///////////////////////****** +////////*,,*/(////////((((////%@%%&&*******//*////((#%%%%%%%%###%&%%%(%%##%&%#%%##########///////////////////////****** +////////**,*/(///////(((((///%@&%&@#*******/**///((#########%%%##%&#%%%%%%%#%%%#((((###///////////////////////******* +////////****/(//////((((((//#@#%###/******////*////(########%%%%%%&%%&%%%%%####%%#######(/////(((((/////////////******* +////////****/(//////((((((/%##%&&&&*******////////(####((((##%%%%%%%%&&%##%#####%######(//////(((((/////////////******/ +////////****/(//////(((((/(&&&&&&&&***////////*///#%%////(##%%%&%%&&&%%#%######%###%(((///(((((//////////////*******/ +////////****/(//////(((/*%&&&&&&@@#****//////////(%&@%%####%%%%&&&&%%%%%#######%#%%///////((((((((///////////*******/ +////////****/(/////(((*/%%%%&&@@@@/***/////////((#%%%%(/(#((%&&&%&&&&&&%%%%%#%%%#%%%///////(((((((((//////////*******// +////////****/(//////***%%%%&@@@@@%****///((////(((####((//(((#%&&%&&&%%%%%&%&&%%#%%(/((//(///((((((////////////******// +////////****/(////***(%%%%%@@@@&@/***////(((((/((((#(((((((((##%%%%%#(##%%%%%%%%%%@&&%##((//(((((/((///////////******// +////////****((//***/#%%%%%%@@&@@#/***////((((((///((((((###%%&&%%&%%%#%%###%%%%%&@@&&&&%%%%####((((///////////******/// +////////****(/**,*/#%%%%%%&@@@@@#///////(((#####((((((((###%%&&&&&&@&%%##%%%%%&@@@@@&&&&&%%#%%#####(//////////******//( +////////********,/%%%%%%%%&@@@@(//////(((###############%%%&&&&%%#####%%%%&@@@@@@@&&&&&&&%%%%%%##(////////******//( +//////*///*******%%%%%%%%&@@@@@&%#(////(((#######%###%#%%%%&&&&&&&%%%%%%%&&@@@@@@@@@&&&@&&&&&%#%%%%%%&&%(/////******//( +//*/((/********/%#%%%%%%%&@@@@@&%%#((//((((##%%####%%%#%%&&&&&&&&&&&&%%&&&@@@@@@@@@&&&&@@&&&&&%%#%%%&%%%%%%##(*****///( +(((///******,,(%%%%%%%%%%%@@@@@@&&%##(((((####%###(###%&&%&&&&@@@@&&&&&&%&@@@@&&@@@&&&&&&&&&&&%%%##%%%%%%%%%%##(/**//(( +/**///*******#%%%##%%%%#%%&@@@@&@&&%%##(((####%%########%%%%%%%&&&&&%%%%&@@@@@@&@@&&&&&&&&%%%%%####%%%%%%%%####/*/((( +//********,*##%##%%%%%###%@@@@@&@@@&%%########%%#######%#%%%%%%%%%%%%%%%@&@@@@@&&@&&&&&&%%%%%%%#%%%%###%%%%%%%%###(/((( +(*****//***##%%##%%%##%##%&@@@@@@@@&&%%%%%%%%%%%%##%%%%%%%&%%%%%%%%%%&@@@@@@@@@&&@&&%%&%&%%####&&%%%#%%##%#%&%%%%###((( +*******/**#%%##%%%%%####%%%@@@@&%@@@@&&%%%%%%%%%%%%%%%%%%%%%%%%%%&@@@@@@&@@@@@@&&@&%%%%%&%%%##%%&&%%%#%%%###%&&%######( +*********#%%#%%%%%%%%##%%%#@@@%@&@@@@@@@@&&%%%%%%%%%%%%%%%%%&@@@@@@@@@@@&@&@@@@&&@%%%###%%%%##%#%&&%%##%%%%###%&%###### +*******/##%#%%#%%%%###%%%##&@@@@@%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&@&@@@@@&&@%%##(#####%%####%&&%%##%%%###%&%##### +((###(((#%#%#%######%%%%%##%@@&&@&%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&&&@@&@@@&@%###(((%###%%####%&%&%##%&%%##%#### +/(#&&@&(%%%%%%%%%#%&%%#%%###@&@@@&&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&&&@@@@@@&@##((#%%%##%#####%%%&%##%&%%##%%#### +((%&@&%###%%##%#%&&%###%%%##&@@@@@%&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&&@@@@@@@&&##(##%%#%##%#####%%%%%##%&&%#%%#### +(%&&&%%/%#%####%&&%%###%%%%#%@@@@@@%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%&@@@@@@&&@###((%#%%####%#####%%%%%##%%&%###### +%&&&&%#%(%###%%&&&%#%##%&&%%#@@@@@@%%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&&&&@@@@@@@&@##(##%##%%####%#####%%%%%#%%&&%##### +&&&&%#%&&&(#%&%%%(#%%#&&&%#@@&&@@@%&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&%@&@@@%@@@@&@%#((#%##%%#####%######%%%%%&%%#### +&&&#%&&&&(#%&&%/####&&&%#@&@@@@@&%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&&&&&@@@@@@@&(##%#%##%%#####%########&%##%&%#### + +Dan +,//////////////((((((((((((//////////////////////////////***************************************,,,,,,,,,,,,........... +,////////////////((((((((((/////////////////////////////////////***///////////////////////((((((((///////////////////// +,//////////////////(((((((((((((///////////////////////////////***********//////////////////((((((((/////////////////// +,//////////////////((((((((((#((((////////////////////////******************//////////////////((((((/////////////////// +,///////////////////(((###########(((//////////***,,,,,,,,,,,,.....,,,*********//////////////////((((////////////////// +,///////////////////((((############(((/////**,,,,,,,,,,,,...,......,,,,,*********///////////////////////////////////// +,////////////////////(((####%#########((/*,,,,,,,,,,...................,,,,,*******/////////////////////(////////////// +,////////////////////(((#############(/,,,,,,,..........................,,,,,,,*****/////////////////////(///////////// +,/**//////////////////(((###########/,,,,,,,...............................,.,,,******///////////////////////////////// +*//*//////////////////(((((#######(/,,,,,,,,.................................,,,,*******/////////////////////////////// +*//////////////////////((((((#####**,,,,,,,....................................,,,*******////////////////////////////// +*//////**//////////////////((((#(*,,,,,,,,,....................................,,,,********////////*****/////////////// +*////////**/////////////////((((/*,,,,,,,,,....................................,,,,**********//////*******///////////// +*/(((((///****//////////////////*,,,,,,,,,.....................................,,,,,*************////*********///////// +*/////////******///////////////**,,,,,,,,,,,...................................,,,,,***************////***********///// +**/////////*******/////////////*,,,,,,,,,..............,........ ...............,,,,,*//************/////**********//// +*******////*********///////////,,,,,,,,..........,,,//(((((((//**,,................,,*//***************/////**********/ +**********************/////////,,,,,,,,........,,,///(/////(####(//*,,...,,,,,,,,,,***///****************////********** +************************//////*,,,,,,,,,...,,*/((((#(((////(((###((/,,.,,,,*///(###((#(//*****************/////******** +***************************///*,,,***((#%%%%%%&&&%#/*****//(((((////%%######%%%%%%%%%%%#/*******************///******** +*//////**********************/*/(#%%%%&&&&%#((/**((**/(###%#((##(//*/#%%%&&%#(((((((((##(#%#//*****************///***** +/////////****//////*********,,,/(/*********///***((*,,,,,,,***///,,,(#*../&%####%%##%###*/(%&%*****************/////*** +/(/////((/((((((///////*****(#(*,.,,,,,,,,,,,,...,(*.......,,,,,.../#*...,#%****//((####&&%##/*******************/////* +((((((((((##((((((///////**/(/*//*,,,,,,,,,,,,....,*/,............*(,...../#*,,********/(/*(**********************///// +(((((((((####((((////////*****,,***,,,,,,,,,,.......,**/((#######/*.......,/(,,.,,...,**/**/***********************//// +((((((((((((((/////////****,,,,*//*,,,....,,.......... ....,,,,,...... .,*/(#####(((((/****************************/ +/////////////////////*******,,.,,.,,,,....................,,***,,...... .,,/*,,,.,,*//(****************************** +****************//////******,,....,,,..................,,,///,..*,,,,,,,..,,*//(**,,,,,*/****************************** +*****************//////*******......,...............,,,*/((*,....**/(((////(#(/*((*****//****************************** +,,,,*************//////********....,,,,,..........,,,*/(/*,......,,,,*/##%%#((////#//////****************************** +*,,,,,,,,,,******////////***********,,,,,,........,,,/(//*,,........,,*/((((((////#((/(((****************************** +*,,,,,,,,,,,,*****/////////******///,,,,,,,......,,,,*//(#((/***,,,...,,,**///((##(///((/****************************** +*,,,,,,,,,,,,,,*****////////////***,,,,,,,,,.....,...,,...*//*. ,..,.,**/((#&&%(**.,,/((/****************************** +**,,,,,,,,,,,,,,,*****//////////**,,,,,,,,,,,.....,,.,*,....,.. ./##//,,,.,*///********//********************* +**,,,,,,,,,,,,,,,,,*****///////**,,,,,,,,,,,,,,,,,,,,,**,....,,... ...,,,////**/*,////*********/******************//** +***,,,,,,,,,,,,,,,,,,,*****////**,,,,,,,,,,**,,,,,,,,*//*,..........,,,,,**//*/////(((*******************************/* +/**********,,,,,,,,,,,,,*****//*,,,,,,,,,,,**,,,,,,,,/((//*,,,.....,,*******///(#((((********************************** +//**********,,,,,,,,,,,,,,******,,,,.,,,,,,,**,,,.,,,//(//*********///////(((//##((/*********************************** +************,,,,,,,,,,,,,,,,,**,,......,,,,,*****,,.,/(#(/*,,/**,*//((///((((((#((************************************* +***********,,,,,,,,,,,,,,,,,,,,,........,,,*******,,*(#(((/*/****,*****//*//(##%/************************************** +***********,,,,,,,,,,,,,,,,,,,,...........,,,***//****/%%%#/////////*/***/((#%%#**************************************, +***************,,,,,,,,,,,,,*,..............,,,**/////**(####(/((((////(((##%%(***************************************, +*****************,,,,,,,,,,///,..............,,,**///(/////##%((((((/(###%%%#/******************************/*********, +*********************,,,,,,,,,*///,....... ...,,,**/(((((((((##%##%%%%##%##(****************************///((((///***, +********************,,,. ..,,,,,,,**#(*. ......,,,**/((((((((############(/****************************//(##%##(///*, +*/////*************...,,,,,,,,,,*,**,*(%(*. ......,,,**/((###############((*****************************///(#%%##(//*, +////////////****,...,..... .....,*******/#%#/,. .....,,***//(((#########(/********************************///((((////, +(/(///////////,............,.......,,,,****#%%#/*......,,,,**//((((###((((************************************////////, +((//////////*... ........,,,....,,.,,,****/(%%%%(*......,,,**//((((((((/*****************************************///, +((((/////*,............,,,...,,.........,*****,*/#%%%%%(*,...,,,**///////(#(//***************************************/, +((((///*,......................,,*//**/*,..,**,*****(%%%%%%#(*,,,,*******(&((/**************************************, +((((/*,......... .........,,,,,.....,,,,,,,,*********/##%%%%%%%#(///***/#&#(/*************************************, +///*...... ..,,,. ............. .,.......,,,,.....,*,,*****/(##%%%%%%%%%&&&&%%%%(**,,*/******************************, +*,......,*,....................... .,,,. .,,*,,.. .,,************/((##%%%%%%%%%%%#***,///,,,,****,********************, +,....,,*,......,,,,......... ..,,,***,,**,..,****,,,,.....,*********//*//**/////*****.*//*,,..*****,,,****************. +,..,,....,**,..,... ..,,,,,,,,,,....,,******, .. ......,*....,*/***********,,*******,//*..,*,,**.,,*,,,,*************. +.,..,.,**..,,....,*****... ........,,...*/*..,,,...***,.,,,,**/***/////////////**,,,..,..,.,/,,,**,.,,************. +..,.,*,.....,*,,,............ ........,......,/*..,*,,,..,,. ...,,,,,,,*******,,******,...***..**,.,,,.....,*********. +,,*,....,**,. ..... ..,,,**,**,,,,,*,**,,...,,,..*,,,,,....,****,,,,,,,,*,,,,,.....,,,,....*..,,.,*,.,,...,.,*********. diff --git a/pom.xml b/pom.xml index c6ec0cc8b..c9dd07359 100644 --- a/pom.xml +++ b/pom.xml @@ -8,12 +8,44 @@ casino 1.0-SNAPSHOT + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.7.0 + + 1.8 + 1.8 + + + + + + + pl.pragmatists + JUnitParams + 1.1.1 + test + + + com.opencsv + opencsv + 4.5 + + + org.junit.jupiter + junit-jupiter + RELEASE + compile + junit junit - 4.12 - test + 4.13-beta-3 + compile + diff --git a/src/.DS_Store b/src/.DS_Store new file mode 100644 index 000000000..6d389a60a Binary files /dev/null and b/src/.DS_Store differ diff --git a/src/main/java/io/zipcoder/casino/Blackjack/BlackjackGame.java b/src/main/java/io/zipcoder/casino/Blackjack/BlackjackGame.java new file mode 100644 index 000000000..eea326d11 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Blackjack/BlackjackGame.java @@ -0,0 +1,294 @@ +package io.zipcoder.casino.Blackjack; + +import io.zipcoder.casino.CardGame; +import io.zipcoder.casino.CardSet; +import io.zipcoder.casino.Interfaces.Game; +import io.zipcoder.casino.Menus.BlackjackMenu; +import io.zipcoder.casino.Player; +import io.zipcoder.casino.Services.GameServices; +import io.zipcoder.casino.Utility.Music; +import io.zipcoder.casino.utilities.Console; + +import java.util.ArrayList; +import java.util.HashMap; + +public class BlackjackGame extends CardGame implements Game { + + private String name = "Blackjack"; + public static final HashMap cardMap = new HashMap(); + static { + for (int i = 2; i <= 10; i++) { + cardMap.put(String.valueOf(i), i); + } + cardMap.put("J",10); + cardMap.put("Q",10); + cardMap.put("K",10); + cardMap.put("A",11); + } + private Console console = new Console(System.in, System.out); + private GameServices gameServices = new GameServices(); + + private double minBet; + private double maxBet; + private BlackjackPlayer player; + private BlackjackNPCPlayer dealer; + private ArrayList hands; + private CardSet shoe; + private int numDecks; + private Music blackJackMusic = null; + + + public BlackjackGame(double minBet, double maxBet, Player incomingPlayer) { + this.minBet = minBet; + this.maxBet = maxBet; + this.player = new BlackjackPlayer(incomingPlayer); + this.dealer = new BlackjackNPCPlayer(new Player("Mr.", "Roboto", 50, 1000000.00), 17, true); + this.numDecks = 5; + this.hands = new ArrayList(0); + } + + public static void main(String[] args) { // for testing + Player player = new Player ("Lem", "Jukes", 23,300.00); + BlackjackGame blackjackGame = new BlackjackGame(0.0,0.0,player); + blackjackGame.startPlay(); + } + + public void setMinBet(double minBet) { + this.minBet = minBet; + } + + public void setMaxBet(double maxBet) { + this.maxBet = maxBet; + } + + @Override + public String getName() { + return name; + } + + public double getMinBet() { + return minBet; + } + + public double getMaxBet() { + return maxBet; + } + + public int getNumDecks() { + return numDecks; + } + + public CardSet getShoe() { + return shoe; + } + + public ArrayList getHands() { + return hands; + } + + public BlackjackPlayer getPlayer() { + return player; + } + + public BlackjackNPCPlayer getDealer() { + return dealer; + } + + public void startPlay() { + //Starts playing music! + try { + Music.filePath = "src/music/(BlackJack) Glide with me.wav"; + blackJackMusic = new Music(); + blackJackMusic.play(); + } catch (Exception ex) { + System.out.println("Error playing sound."); + ex.printStackTrace(); + } + + new BlackjackMenu(this).displayMenu(); + if (this.minBet != 0.0) { + roundStart(); + } + + blackJackMusic.stop(); + + } + + public void roundStart() { + console.printWithDelays(""); + Double betSize = betChoice(); + if (betSize != null) { + initialDeal(betSize); + + if (initialWinnerCheck()) { + displayTable(true); + } else { + displayTable(false); + + roundOfPlay(); + } + clearHands(); + roundStart(); + } + + } + + public Double betChoice () { + Double wager; + console.printWithDelays(String.format("\n[DEALER]: Current bankroll: $%.2f\n", this.player.getPlayer().getBalance()),10); + wager = console.getCurrency("\n[DEALER]: Bet size (or press Enter to stand up) \n\n", this.minBet, this.maxBet); + if (wager != null) { + if (gameServices.wager(wager, this.player.getPlayer())) { + return wager; + } else { + console.printWithDelays(String.format("\n[DEALER]: Your mouth is writing checks that your wallet can't cash, %s.", this.player.getPlayer().getLastName())); + console.println("(\nGo to the Teller to pull out money)"); + return betChoice(); + } + } else { + return null; + } + } + + + + public void initialDeal(double betSize) { + + checkShoe(); + BlackjackHand playerHand = new BlackjackHand(betSize, this.player, this.shoe.removeFirstCard(), this.shoe.removeFirstCard()); + + this.hands.add(playerHand); + this.player.addHand(playerHand); + + NPCBlackjackHand dealerHand = new NPCBlackjackHand(0.00, (BlackjackPlayer) this.dealer, this.shoe.removeFirstCard(), this.shoe.removeFirstCard()); + this.hands.add(dealerHand); + this.dealer.addHand(dealerHand); + + } + + public void roundOfPlay() { + int handNum = this.player.getHands().size(); + for (int i = 0; i < handNum; i++) { + int value = -1; + while (value < 0) { + value = this.player.getHands().get(i).playChoice(this.shoe); + handNum = this.player.getHands().size(); + this.displayTable(false); + } + } + for (BlackjackHand hand : this.dealer.getHands()) { + int value = -1; + while (value < 0) { + value = hand.playChoice(this.shoe); + this.displayTable(false); + } + } + displayTable(true); + } + + public void clearHands() { + this.hands.clear(); + this.player.getHands().clear(); + this.dealer.getHands().clear(); + } + + public void endChoice() { + + } + + public void checkShoe() { + if (this.shoe == null || this.shoe.size() < this.numDecks * 26) { + this.shoe = getNewShoe(); + } + } + + public CardSet getNewShoe() { + CardSet newShoe = new CardSet(this.numDecks); + newShoe.shuffle(); + return newShoe; + } + + public void displayTable(boolean showWinnings) { + //temporary + console.clearScreen(); + + System.out.println(String.format(" .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. \n" + + "| .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. |\n" + + "| | ______ | || | _____ | || | __ | || | ______ | || | ___ ____ | || | _____ | || | __ | || | ______ | || | ___ ____ | |\n" + + "| | |_ _ \\ | || | |_ _| | || | / \\ | || | .' ___ | | || | |_ ||_ _| | || | |_ _| | || | / \\ | || | .' ___ | | || | |_ ||_ _| | |\n" + + "| | | |_) | | || | | | | || | / /\\ \\ | || | / .' \\_| | || | | |_/ / | || | | | | || | / /\\ \\ | || | / .' \\_| | || | | |_/ / | |\n" + + "| | | __'. | || | | | _ | || | / ____ \\ | || | | | | || | | __'. | || | _ | | | || | / ____ \\ | || | | | | || | | __'. | |\n" + + "| | _| |__) | | || | _| |__/ | | || | _/ / \\ \\_ | || | \\ `.___.'\\ | || | _| | \\ \\_ | || | | |_' | | || | _/ / \\ \\_ | || | \\ `.___.'\\ | || | _| | \\ \\_ | |\n" + + "| | |_______/ | || | |________| | || ||____| |____|| || | `._____.' | || | |____||____| | || | `.___.' | || ||____| |____|| || | `._____.' | || | |____||____| | |\n" + + "| | | || | | || | | || | | || | | || | | || | | || | | || | | |\n" + + "| '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' |\n" + + " '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' \n" + "\n" + "\n" + "\n" + + + "\nTable stakes: $%.2f min / $%.2f max\n", this.minBet, this.maxBet)); + console.println("[Dealer's Hand]:"); + BlackjackHand dealerHand = this.dealer.getHands().get(0); + + console.print(dealerHand.getCards().toASCII()); + console.println("\n"); + console.println(String.format("[%s's Hand(s)]:",this.player.getPlayer().getFirstName())); + ArrayList playerHands = this.player.getHands(); + for (BlackjackHand hand : playerHands) { + console.print(hand.getCards().toASCII()); + console.print(" $%.2f", hand.getBet()); + if (showWinnings) { + console.print(winningMessage(hand)); + } + console.println("\n"); + } + + } + + public String winningMessage(BlackjackHand hand) { + String message = " ----> "; + double winnings = calculateWinnings(hand); + if (winnings == hand.getBet()) { + message += "Push"; + } else if (winnings == 0.0) { + message += "((Dealer wins))"; + } else { + message += String.format("Winnings: $%.2f",winnings); + } + return message; + } + + public boolean initialWinnerCheck() { // looking for blackjacks + BlackjackHand dealerHand = this.dealer.getHands().get(0); // dealer only ever has one hand + BlackjackHand playerHand = this.player.getHands().get(0); // player starts with only one hand + int dealerValue = dealerHand.getValue(); + int playerValue = playerHand.getValue(); + + if (dealerValue == 21 && playerValue < 21 //lose to blackjack + || dealerValue < 21 && playerValue == 21 //win w/ blackjack + || dealerValue == 21 && 21 == playerValue) { //push w/blackjacks + return true; + } + return false; + } + + // returns 0 if you lost, bet size if you pushed, 2x bet size if you won + public double calculateWinnings (BlackjackHand handToEvaluate) { + + BlackjackHand dealerHand = this.dealer.getHands().get(0); // dealer only ever has one hand + int dealerValue = dealerHand.getValue(); + int playerValue = handToEvaluate.getValue(); + if (playerValue > dealerValue) { + if (handToEvaluate.getCards().size() == 2 && handToEvaluate.getValue() == 21) { + gameServices.payOut(2.5 * handToEvaluate.getBet(), this.player.getPlayer()); + return 2.5 * handToEvaluate.getBet(); + } + gameServices.payOut(2 * handToEvaluate.getBet(), this.player.getPlayer()); + return 2 * handToEvaluate.getBet(); + } else if (playerValue == dealerValue) { + gameServices.payOut(handToEvaluate.getBet(), this.player.getPlayer()); + return handToEvaluate.getBet(); + } else { + return 0.0; + } + } + +} diff --git a/src/main/java/io/zipcoder/casino/Blackjack/BlackjackHand.java b/src/main/java/io/zipcoder/casino/Blackjack/BlackjackHand.java new file mode 100644 index 000000000..d8f3608e5 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Blackjack/BlackjackHand.java @@ -0,0 +1,136 @@ +package io.zipcoder.casino.Blackjack; + +import io.zipcoder.casino.Card; +import io.zipcoder.casino.CardSet; +import io.zipcoder.casino.Services.GameServices; +import io.zipcoder.casino.utilities.Console; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.logging.Logger; + +public class BlackjackHand { + + private CardSet cards; + private double bet; + private int value; + private BlackjackPlayer player; + private Console console = new Console(System.in, System.out); + private GameServices gameServices = new GameServices(); + private Logger logger = Logger.getLogger(BlackjackHand.class.getName()); + + public BlackjackHand(double bet, BlackjackPlayer player, Card card1, Card card2) { + this.bet = bet; + this.player = player; + this.cards = new CardSet(0); + this.cards.addCard(card1); + if (card2 != null) { + this.cards.addCard(card2); + } + } + + public CardSet getCards() { + return cards; + } + + public double getBet() { + return bet; + } + + public BlackjackPlayer getPlayer() { + return player; + } + + public void setBet(double bet) { + this.bet = bet; + } + + public void setCards(CardSet cards) { //just for testing + this.cards = cards; + } + + public void clear() { + this.cards.clear(); + } + + public void addCard(Card card) { + this.cards.addCard(card); + + } + + public int size() { + return this.cards.size(); + } + + public int playChoice(CardSet shoe){ + if (this.cards.size() == 2 && this.cards.getCards().get(0).equals(this.cards.getCards().get(1))) { + splitHand(); + return -1; + } else { // normal case + console.printWithDelays("1. Hit\n2. Stay\n"); + + switch (console.menuChoice(2)) { + case 1: + int val = hit(shoe.removeFirstCard()); + if (val != 0) { + return -1; + } else { + return 0; + } + case 2: + return this.getValue(); + } + return -1; + } + + } + + public int hit(Card card) { + this.cards.addCard(card); + this.value = getValue(); + return this.value; + } + + public void splitHand() { + Card card = this.cards.removeFirstCard(); + this.player.addHand(new BlackjackHand(this.bet, this.player, card, null)); + gameServices.wager(this.bet, this.player.getPlayer()); + } + + public int getValue() { + ArrayList values = mapCardValues(this.cards); + int sumValue = arraySum(values); + if (sumValue <= 21) { + return sumValue; + } else { + if (values.contains(11)) { + int numAces = values.size() - values.indexOf(11); + for (int i = 1; i <= numAces; i++) { // loop through, turning 11's into 1's until it's legal + sumValue -= 10; + if (sumValue <= 21) { + return sumValue; + } + } + } + return 0; //bust + } + } + + public ArrayList mapCardValues(CardSet cards) { + ArrayList values = new ArrayList(); + for (Card card: cards.getCards()) { + values.add(BlackjackGame.cardMap.get(card.getRank())); + } + Collections.sort(values); + return values; + } + + public int arraySum(ArrayList array) { + int sum = 0; + for (int number : array) { + sum += number; + } + return sum; + } + +} diff --git a/src/main/java/io/zipcoder/casino/Blackjack/BlackjackNPCPlayer.java b/src/main/java/io/zipcoder/casino/Blackjack/BlackjackNPCPlayer.java new file mode 100644 index 000000000..077a4046e --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Blackjack/BlackjackNPCPlayer.java @@ -0,0 +1,33 @@ +package io.zipcoder.casino.Blackjack; + +import io.zipcoder.casino.Player; + +import java.util.ArrayList; + +public class BlackjackNPCPlayer extends BlackjackPlayer { + + private int threshold; + private boolean isDealer; + private ArrayList hands; + private Player player; + + public BlackjackNPCPlayer(Player player, int threshold, boolean isDealer) { + super(player); + this.threshold = threshold; + this.isDealer = isDealer; + } + + public int getThreshold() { + return threshold; + } + + public boolean isDealer() { + return isDealer; + } + + public Player getPlayer() { + return player; + } + + +} diff --git a/src/main/java/io/zipcoder/casino/Blackjack/BlackjackPlayer.java b/src/main/java/io/zipcoder/casino/Blackjack/BlackjackPlayer.java new file mode 100644 index 000000000..152ae81f2 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Blackjack/BlackjackPlayer.java @@ -0,0 +1,34 @@ +package io.zipcoder.casino.Blackjack; + +import io.zipcoder.casino.Player; + +import java.util.ArrayList; + +public class BlackjackPlayer { + + private ArrayList hands; + private Player player; + + public BlackjackPlayer(Player player) { + this.player = player; + this.hands = new ArrayList(); + } + + public ArrayList getHands() { + return hands; + } + + public Player getPlayer() { + return player; + } + + public void addHand(BlackjackHand hand) { + hands.add(hand); + } + + public void removeHand(BlackjackHand hand) { + hands.remove(hand); + } + + +} diff --git a/src/main/java/io/zipcoder/casino/Blackjack/NPCBlackjackHand.java b/src/main/java/io/zipcoder/casino/Blackjack/NPCBlackjackHand.java new file mode 100644 index 000000000..9309b5a89 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Blackjack/NPCBlackjackHand.java @@ -0,0 +1,29 @@ +package io.zipcoder.casino.Blackjack; + +import io.zipcoder.casino.Card; +import io.zipcoder.casino.CardSet; +import io.zipcoder.casino.utilities.Console; + +public class NPCBlackjackHand extends BlackjackHand { + + private Console console = new Console(System.in, System.out); + + public NPCBlackjackHand(double bet, BlackjackPlayer player, Card card1, Card card2) { + super(bet, player, card1, card2); + } + + @Override + public int playChoice(CardSet shoe) { + console.sleep(500); + if (this.getValue() <= ((BlackjackNPCPlayer) this.getPlayer()).getThreshold()) { + int val = hit(shoe.removeFirstCard()); + if (val != 0) { + return -1; + } else { + return 0; + } + } + return this.getValue(); + } + +} diff --git a/src/main/java/io/zipcoder/casino/Card.java b/src/main/java/io/zipcoder/casino/Card.java new file mode 100644 index 000000000..826bec550 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Card.java @@ -0,0 +1,64 @@ +package io.zipcoder.casino; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; + +public class Card implements Comparable{ + + private String rank; + private String suit; //H,C,S,D + public static final ArrayList RANKS; + public static final HashMap SUIT_SYMBOLS; + static { + RANKS = new ArrayList(Arrays.asList(new String[]{"2","3","4","5","6","7","8","9","10","J","Q","K","A"})); + SUIT_SYMBOLS = new HashMap(); + SUIT_SYMBOLS.put("H","\u2665"); + SUIT_SYMBOLS.put("S","\u2660"); + SUIT_SYMBOLS.put("C","\u2663"); + SUIT_SYMBOLS.put("D","\u2666"); + } + + public Card(String rank, String suit) { + this.rank = rank; + this.suit = suit; + } + + public String getRank() { + return rank; + } + + public String getSuit() { + return suit; + } + + public int compareTo (Card card2) { + if (!this.rank.equals(card2.rank)) { + return Integer.compare(Card.RANKS.indexOf(this.rank), Card.RANKS.indexOf(card2.rank)); + } else { + int res = Card.SUIT_SYMBOLS.get(this.suit).compareTo(Card.SUIT_SYMBOLS.get(card2.suit)); + return (res > 0) ? 1 : (res == 0 ) ? 0 : -1; + } + } + + public boolean equals (Card card2) { + if (this.rank.equals(card2.rank)) { + return true; + } else { + return false; + } + } + + public boolean strictEquals (Card card2) { + if (this.compareTo(card2) == 0 && this.suit == card2.suit) { + return true; + } else { + return false; + } + } + + @Override + public String toString() { + return this.rank + SUIT_SYMBOLS.get(this.suit); + } +} diff --git a/src/main/java/io/zipcoder/casino/CardGame.java b/src/main/java/io/zipcoder/casino/CardGame.java new file mode 100644 index 000000000..294ae53e3 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/CardGame.java @@ -0,0 +1,6 @@ +package io.zipcoder.casino; + + +public abstract class CardGame extends GameObject { + +} diff --git a/src/main/java/io/zipcoder/casino/CardSet.java b/src/main/java/io/zipcoder/casino/CardSet.java new file mode 100644 index 000000000..e08109cda --- /dev/null +++ b/src/main/java/io/zipcoder/casino/CardSet.java @@ -0,0 +1,168 @@ +package io.zipcoder.casino; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; + +public class CardSet { + + private ArrayList cards; + + public CardSet(int numDecks) { + //creates shuffled set of cards + ArrayList cardSet = new ArrayList(numDecks * 52); + if (numDecks > 0) { + for (int i = 0; i < numDecks; i++) { + for (String rank : Card.RANKS) { + for (String suit : Card.SUIT_SYMBOLS.keySet()) { + cardSet.add(new Card(rank, suit)); + } + } + } + } + + this.cards = cardSet; + } + + public ArrayList getCards() { + cards.trimToSize(); + return cards; + } + + public int size() { + return this.cards.size(); + } + + public Card removeFirstCard() { + // removes first card! + if (this.cards.size() > 0) { + Card card = this.cards.remove(this.cards.size()-1); + return card; + } else { + return null; + } + } + + public ArrayList removeRank(String rankToRemove) { + ArrayList foundCards = new ArrayList(); + if (this.cards.size() > 0) { + for (int i = 0; i < this.cards.size(); i++) { + if (rankToRemove.equals(this.cards.get(i).getRank())) { + foundCards.add(this.cards.remove(i)); + i--; + } + } + } + return foundCards; + } + + public void addCard(Card cardToAdd) { + this.cards.add(cardToAdd); + } + + public void addCards(ArrayList cardsToAdd) { + for (Card card : cardsToAdd) { + this.cards.add(card); + } + } + + public void clear() { + this.cards.clear(); + } + + public void sort() { + Collections.sort(this.cards); + } + + public void shuffle() { + + Collections.shuffle(this.cards); + //ArrayList c = this.cards; + } + + + public String toASCII() { + int numCards = this.size(); + if (numCards >0) { + String[] emptyArray = new String[numCards + 1]; + Arrays.setAll(emptyArray, (index) -> ""); + + String output = String.join("\u250C-------\u2510 ", emptyArray); + output += "\n"; + for (Card card : this.cards) { + if (card.getRank().length() == 1) { + output += String.format("| %s | ", card.getRank()); + } else { + output += String.format("|%s | ", card.getRank()); + } + } + output += "\n"; + output += String.join("| | ", emptyArray); + output += "\n"; + for (Card card : this.cards) { + output += String.format("| %s | ", Card.SUIT_SYMBOLS.get(card.getSuit())); + } + output += "\n"; + output += String.join("| | ", emptyArray); + output += "\n"; + for (Card card : this.cards) { + if (card.getRank().length() == 1) { + output += String.format("| %s | ", card.getRank()); + } else { + output += String.format("| %s| ", card.getRank()); + } + } + output += "\n"; + output += String.join("\u2514-------\u2518 ", emptyArray); + output += "\n"; + return output; + } else { + return ""; + } + } + + public String toASCIIBlank() { + int numCards = this.size(); + if (numCards >0) { + String[] emptyArray = new String[numCards + 1]; + Arrays.setAll(emptyArray, (index) -> ""); + + String output = String.join("\u250C-------\u2510 ", emptyArray); + output += "\n"; + output += String.join("| | ", emptyArray); + output += "\n"; + output += String.join("| | ", emptyArray); + output += "\n"; + output += String.join("| | ", emptyArray); + output += "\n"; + output += String.join("| | ", emptyArray); + output += "\n"; + output += String.join("| | ", emptyArray); + output += "\n"; + output += String.join("\u2514-------\u2518 ", emptyArray); + output += "\n"; + return output; + } else { + return ""; + } + } + + public String toASCIISuite() { + int numCards = this.size(); + if (numCards >0) { + String[] emptyArray = new String[numCards + 1]; + Arrays.setAll(emptyArray, (index) -> ""); + + String output = toASCII(); + output += " "; + output += String.join("\u2514-------\u2518 ", emptyArray); + output += "\n"; + output += " "; + output += String.join("\u2514-------\u2518 ", emptyArray); + output += "\n"; + return output; + } else { + return ""; + } + } +} diff --git a/src/main/java/io/zipcoder/casino/Casino.java b/src/main/java/io/zipcoder/casino/Casino.java deleted file mode 100644 index 16ca0dd74..000000000 --- a/src/main/java/io/zipcoder/casino/Casino.java +++ /dev/null @@ -1,8 +0,0 @@ -package io.zipcoder.casino; - - -public class Casino { - public static void main(String[] args) { - // write your tests before you start fucking with this - } -} diff --git a/src/main/java/io/zipcoder/casino/Craps/CrapsGame.java b/src/main/java/io/zipcoder/casino/Craps/CrapsGame.java new file mode 100644 index 000000000..6d056e95c --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Craps/CrapsGame.java @@ -0,0 +1,288 @@ +package io.zipcoder.casino.Craps; + +import io.zipcoder.casino.DiceGame; +import io.zipcoder.casino.Interfaces.Game; +import io.zipcoder.casino.Menus.CrapsMenu; +import io.zipcoder.casino.Player; +import io.zipcoder.casino.Services.GameServices; +import io.zipcoder.casino.utilities.Console; +import io.zipcoder.casino.Utility.Music; + +public class CrapsGame extends DiceGame implements Game { + + public static void main(String[] args) throws InterruptedException { + Player player = new Player ("Jeff","Smith", 28, 300.00); + CrapsGame crapsGame = new CrapsGame(10.00,50.00,player); + crapsGame.startPlay(); + } + private String name = "Craps"; + private double minBet; + private double maxBet; + private CrapsPlayer player; + private Integer setThePointRoll; //saves your first roll to try to match with later rolls + private Integer currentRoll; //any roll after the first + private Integer numRolls = 0; + private Console console = new Console(System.in, System.out); + private GameServices gameServices = new GameServices(); + private Music crapsMusic = null; + private Integer die1Point; + private Integer die2Point; + private Integer die1Current; + private Integer die2Current; + private Double winnings = 0D; + private Double wager = 0D; + + + + + //Craps Game Constructor + public CrapsGame(double minBet, double maxBet, Player incomingPlayer) { + this.minBet = minBet; + this.maxBet = maxBet; + this.player = new CrapsPlayer(incomingPlayer); + } + + + @Override + //creates and runs a roundOfPlay + public void startPlay() { + try { + Music.filePath = "src/music/(Craps) Amor maior - Higher Love.wav"; + crapsMusic = new Music(); + crapsMusic.play(); + } catch (Exception ex) { + console.println("Error with playing sound."); + ex.printStackTrace(); + } + new CrapsMenu(this).displayMenu(); + + roundOfPlay(); + crapsMusic.stop(); + } + + @Override + //runs a new game of craps + public void roundOfPlay() { + Double betSize = betChoice(); + if (betSize > 0) { + userRollsDiceSetPoint(); + console.println(displayPointRoll()); + if (winOnFirst(setThePointRoll) == true) { + winnings = calculateWinnings(betSize, setThePointRoll, numRolls); + console.println(winningMessageFirstRoll()); + + } else if (loseOnFirst(setThePointRoll) == true) { + console.println(losingMessageFirstRoll()); + } else { + for (int i = 0; i < 3; i++) { + numRolls = i + 1; + userRollsDiceCurrentPoint(); + console.println(displayCurrentRoll(currentRoll)); + if (winOnSubsequent(currentRoll, setThePointRoll) == true) { + winnings = calculateWinnings(betSize, setThePointRoll, numRolls); + console.printWithDelays(winOnSubsequentMessage(), 50); + break; + } else if (loseOnSubsequent(currentRoll) == true) { + console.println(loseOnSubsequentMessage()); + break; + } + if (i == 2) { + console.println(losingMessageOutOfRolls()); + } + } + } + endChoice(); + } + } + + + public Double betChoice() { + console.println(String.format("\nCurrent bankroll: $%.2f", this.player.getPlayer().getBalance())); + wager = console.getCurrency(String.format("\n[CROUPIER]: The limits here are %.2f and %.2f\n[CROUPIER]: What's your Bet? (0 to leave the table)\n\n", this.minBet, this.maxBet)); + if (wager > 0) { + // betting more than player has + if (wager > this.player.getPlayer().getBalance()) { + console.println(String.format("\n[CROUPIER]: Your mouth is writing checks that your wallet can't cash, %s.\n", this.player.getPlayer().getLastName())); + betChoice(); + } // betting outside table limits + else if (wager < this.minBet || wager > this.maxBet) { + console.println(String.format("\n[CROUPIER]: You're not playing within the table limits, %s.\n", this.player.getPlayer().getLastName())); + betChoice(); + } // wager ok + else { + gameServices.wager(wager, this.player.getPlayer()); + } + } + return wager; + } + + public Double calculateWinnings(Double wager, Integer setThePointRoll, Integer numRolls){ + // PUT THE PAY TABLE HERE + if (setThePointRoll == 7 || setThePointRoll == 11){ + gameServices.payOut(2 * wager, this.player.getPlayer()); + return 2 * wager; + } + else if (setThePointRoll == 4 || setThePointRoll == 10){ + gameServices.payOut((7 - numRolls) * wager, this.player.getPlayer()); + return (7 - numRolls) * wager; + } + else if (setThePointRoll == 5 || setThePointRoll == 9){ + gameServices.payOut((6 - numRolls) * wager, this.player.getPlayer()); + return (6 - numRolls) * wager; + } + else if (setThePointRoll == 6 || setThePointRoll == 8){ + gameServices.payOut((5 - numRolls) * wager, this.player.getPlayer()); + return (5 - numRolls) * wager; + } + return 0.0; + } + + @Override + //implements menu whether you want to quit or go again + public void endChoice() { + String endChoiceInput = console.getInput("\n[CROUPIER]: You have finished this game of Craps.\n\nWould you like to play again? (Y/N)\n"); + if (endChoiceInput.toUpperCase().equals("N")) { + + crapsMusic.stop(); + + console.println("\n[CROUPIER]: Have a good rest of your day.\n"); + //Return to games menu from here + } else if (endChoiceInput.toUpperCase().equals("Y")) { + console.println("\n[CROUPIER]: That's great!!!\n"); + + roundOfPlay(); + } else { + console.println("\n[CROUPIER]: That's not a valid selection. Please choose again."); + endChoice(); + } + } + + public boolean winOnFirst(Integer setThePointRoll) { + if (setThePointRoll == 7 || setThePointRoll == 11) { + return true; + } else { + return false; + } + } + + public boolean loseOnFirst(Integer setThePointRoll) { + if (setThePointRoll == 2 || setThePointRoll == 3 || setThePointRoll == 12) { + return true; + } else { + return false; + } + } + + + public boolean winOnSubsequent(Integer currentRoll, Integer setThePointRoll) { + if (currentRoll.equals(setThePointRoll)) { + return true; + } + return false; + } + + public boolean loseOnSubsequent(Integer currentRoll) { + if (currentRoll == 7) { + return true; + } + return false; + } + + public void userRollsDiceSetPoint() { + console.getInput("\nPress Enter to roll the dice\n"); + die1Point = roll(); + die2Point = roll(); + tossPointRoll(die1Point, die2Point); + } + + public void userRollsDiceCurrentPoint() { + console.getInput(String.format("-------------------------------------------------\nSet the Point Roll: %d\nPress Enter to roll the dice\n", setThePointRoll)); + die1Current = roll(); + die2Current = roll(); + tossCurrentRoll(die1Current, die2Current); + + } + + + public Integer tossPointRoll(Integer die1Point, Integer die2Point) { + setThePointRoll = die1Point + die2Point ; + return setThePointRoll; + } + + + public String displayPointRoll() { + return ("\n-------------------------------------------------") + ("SET THE POINT ROLL:\n" + DiceGame.diceToASCII(die1Point, die2Point) + "\n-------------------------------------------------"); + //console.println(String.format("\n(( You have rolled a %d for your set the point roll. ))\n", setThePointRoll)); + } + + public String displayCurrentRoll(Integer currentRoll) { + return (DiceGame.diceToASCII(die1Current, die2Current)) + String.format("\n(( You have rolled a %d for this roll. ))\n", currentRoll); + } + + public String winningMessageFirstRoll() { + return String.format("\n(( You rolled a %d on the first roll! ))\n\nCongratulations!!\n\nYou won $%.2f!!!\n-------------------------------------------------\n\n", setThePointRoll, winnings-wager); + } + + public String losingMessageFirstRoll() { + return (String.format("\n(( You rolled a %d and have lost on the first roll! ))\n\nThis is unfortunate.....\n\n:(\n-------------------------------------------------\n\n", setThePointRoll)); + } + + public String losingMessageOutOfRolls() { + return String.format("(( You are out of rolls. ))\nYou seem to have lost.\nThis is unfortunate.....\n:(\n-------------------------------------------------\n\n"); + + } + + public Integer tossCurrentRoll(Integer die1Current, Integer die2Current) { + currentRoll = die1Current + die2Current; + return currentRoll; + + } + + + public String winOnSubsequentMessage (){ + return (String.format("Hooray! You rolled a %d, and you have won $%.2f!! It took you %d rolls to win.", currentRoll, winnings-wager, numRolls)); + } + + public String loseOnSubsequentMessage () { + return (String.format("It appears that the odds were not in your favor today. Better luck next time.....\n-------------------------------------------------\n\n")); + } + + public Integer getDie1Current() { + return die1Current; + } + + public Integer getDie2Current() { + return die2Current; + } + + public void setDie1Current (Integer die1Current1) { + this.die1Current = die1Current1; + } + + public void setDie2Current (Integer die2Current1) { + this.die2Current = die2Current1; + } + + public Integer getDie1Point() { + return die1Point; + } + + public void setDie1Point(Integer die1Point) { + this.die1Point = die1Point; + } + + public Integer getDie2Point() { + return die2Point; + + } + + public void setDie2Point(Integer die2Point) { + this.die2Point = die2Point; + } + + public String getName() { + return name; + } +} + + diff --git a/src/main/java/io/zipcoder/casino/Craps/CrapsPlayer.java b/src/main/java/io/zipcoder/casino/Craps/CrapsPlayer.java new file mode 100644 index 000000000..fc86961f4 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Craps/CrapsPlayer.java @@ -0,0 +1,21 @@ +package io.zipcoder.casino.Craps; + +import io.zipcoder.casino.Player; + +public class CrapsPlayer { + + private Player player; + + + //CrapsPlayer Constructor + public CrapsPlayer(Player player) { + + this.player = player; + } + + public Player getPlayer(){ + return this.player; + } + + +} diff --git a/src/main/java/io/zipcoder/casino/DiceGame.java b/src/main/java/io/zipcoder/casino/DiceGame.java new file mode 100644 index 000000000..16aa19ccf --- /dev/null +++ b/src/main/java/io/zipcoder/casino/DiceGame.java @@ -0,0 +1,78 @@ +package io.zipcoder.casino; + +import java.util.Arrays; +import java.util.Random; + +public abstract class DiceGame extends GameObject { + + + //Rolls any number of dice with any number of sides + public static int roll (int numberOfDiceBeingRolled, int numOfSides) + { + Integer dieRoll1 = 0; + for (int i = 1; i <= numberOfDiceBeingRolled; i++) { + dieRoll1 += (int) (Math.random() * numOfSides + 1); + } + return dieRoll1; + } + + //Rolls just one die with 6 sides + public static int roll () { + + return roll(1,6); + } + + public static int roll (int numberOfDiceBeingRolled){ + return roll(numberOfDiceBeingRolled, 6); + } + + public static String diceToASCII(int... dice) { + int numDice = dice.length; + String[] emptyArray = new String[numDice+1]; + Arrays.setAll(emptyArray,(index) -> ""); + + String output = String.join(" ________ ", emptyArray); + output += "\n"; + output += String.join(" / /| ", emptyArray); + output += "\n"; + output += String.join(" / / | ", emptyArray); + output += "\n"; + output += String.join("\u250C-------\u2510 | ", emptyArray); + output += "\n"; + for (int num : dice) { + if (num >= 4) { + output += "| \u2022 \u2022 | / "; + } else if (num > 1) { + output += "| \u2022 | / "; + } else { + output += "| | / "; + } + } + output += "\n"; + for (int num : dice) { + if (num % 2 == 1) { + output += "| \u2022 | / "; + } else if (num == 6) { + output += "| \u2022 \u2022 | / "; + } else { + output += "| | / "; + } + } + output += "\n"; + for (int num : dice) { + if (num >= 4) { + output += "| \u2022 \u2022 |/ "; + } else if (num > 1) { + output += "| \u2022 |/ "; + } else { + output += "| |/ "; + } + } + output += "\n"; + output += String.join("\u2514-------\u2518 ", emptyArray); + output += "\n"; + return output; + } + + +} diff --git a/src/main/java/io/zipcoder/casino/GameObject.java b/src/main/java/io/zipcoder/casino/GameObject.java new file mode 100644 index 000000000..7790b154e --- /dev/null +++ b/src/main/java/io/zipcoder/casino/GameObject.java @@ -0,0 +1,25 @@ +package io.zipcoder.casino; + +import io.zipcoder.casino.Interfaces.Game; + +public class GameObject implements Game { + + private String name; + + public String getName() { + return this.name; + } + + public void startPlay() { + + } + + public void roundOfPlay() { + + } + + public void endChoice() { + + } + +} diff --git a/src/main/java/io/zipcoder/casino/GoFish/GoFishGame.java b/src/main/java/io/zipcoder/casino/GoFish/GoFishGame.java new file mode 100644 index 000000000..1c0f33db9 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/GoFish/GoFishGame.java @@ -0,0 +1,293 @@ +package io.zipcoder.casino.GoFish; + +import io.zipcoder.casino.Card; +import io.zipcoder.casino.CardGame; +import io.zipcoder.casino.CardSet; +import io.zipcoder.casino.Interfaces.Game; +import io.zipcoder.casino.Menus.GoFishMenu; +import io.zipcoder.casino.Player; +import io.zipcoder.casino.Utility.Music; +import io.zipcoder.casino.utilities.Console; + +import java.util.ArrayList; + +public class GoFishGame extends CardGame implements Game { + + + private Console console = new Console(System.in, System.out); + + private String name = "Go Fish"; + private GoFishPlayer player; + private GoFishNPC opponent; + private CardSet shoe; + private CardSet playersCards; + private CardSet opponentsCards; + private CardSet playerSuites; + private CardSet opponentSuites; + private Music fishMusic = null; + private String actingPlayer; + private ArrayList stolenCards; + private String message = ""; + private Card fishedCard; + + + + public GoFishGame(Player player) { + this.player = new GoFishPlayer(player); + this.opponent = new GoFishNPC(new Player("Baity", "McSwitch", 55, 0)); + this.playersCards = new CardSet(0); + this.opponentsCards = new CardSet(0); + this.playerSuites = new CardSet(0); + this.opponentSuites = new CardSet(0); + this.shoe = new CardSet(1); + } + + public static void main(String[] args) { // for testing + Player player = new Player("Lem", "Jukes", 23, 300.00); + GoFishGame goFishGame = new GoFishGame(player); + goFishGame.startPlay(); + } + + public void setupGame(){ + startPlay(); + } + + //populates player deals hands + public void startPlay() { + resetGame(); + try { + Music.filePath = "src/music/(Go Fish) Underwater Theme GuitarMarimba Cover - Super Mario Bros. 1.wav"; + fishMusic = new Music(); + fishMusic.play(); + } catch (Exception ex) { + System.out.println("Error with playing sound."); + ex.printStackTrace(); + } + new GoFishMenu().displayMenu(); + goTitleScreen(); + initialDeal(); + turn(this.player, this.opponent, this.playersCards, this.opponentsCards, this.playerSuites, this.opponentSuites); + } + + public void initialDeal() { + shoe.shuffle(); + for (int i = 0; i < 7; i++) { + this.playersCards.addCard(this.shoe.removeFirstCard()); + this.opponentsCards.addCard(this.shoe.removeFirstCard()); + } + } + + public CardSet integrateStolenCards(ArrayList stolenCards, CardSet hand) { + System.out.println("SUCCESSFULLY TOOK " + stolenCards.size() + " " + stolenCards.get(0).getRank() + "'S"); + hand.addCards(stolenCards); + return hand; + } + + public Card drawCard(CardSet hand) { + console.println("OoOoOoO GO FISH! OoOoOoO"); + Card fishedCard = shoe.removeFirstCard(); + hand.addCard(fishedCard); + hand.sort(); + return fishedCard; + } + + public void emptyHandDraw(CardSet hand) { + if (hand.size() <= 0) { + hand.addCard(shoe.removeFirstCard()); + } + } + + public boolean scanForSuites(CardSet hand, CardSet currentPlayerSuites, String rankToCheck) { + ArrayList suiteChecker = hand.removeRank(rankToCheck); + if (suiteChecker.size() == 4) { + console.println("NEW SUITE: " + suiteChecker.get(0)); + currentPlayerSuites.addCard(suiteChecker.get(0)); + return true; + } else { + hand.addCards(suiteChecker); + } + hand.sort(); + return false; + } + + public void turn(GoFishPlayer playerUp, GoFishPlayer nextPlayer, CardSet playerUpCards, CardSet nextPlayerCards, CardSet playerUpSuites, CardSet nextPlayerSuites) { + + GoFishPlayer winStatus = checkForWin(playerUp, nextPlayer, playerUpSuites, nextPlayerSuites); + announceWinner(winStatus); + String cardChoice = ""; + fishedCard = null; + if (winStatus == null) { + emptyHandDraw(playerUpCards); + console.clearScreen(); + displayStatus(); + cardChoice = playerUp.chooseCard(playerUpCards); + actingPlayer = playerUp.getPlayer().getFirstName(); + } + if (!cardChoice.equals("N") && winStatus == null) { + stolenCards = nextPlayerCards.removeRank(cardChoice); + + if (stolenCards.size() > 0) { // successfully took from opponent + integrateStolenCards(stolenCards, playerUpCards); + // scan and get another turn + scanForSuites(playerUpCards, playerUpSuites, cardChoice); + message = createMessage(playerUp, stolenCards, cardChoice, fishedCard); + turn(playerUp, nextPlayer, playerUpCards, nextPlayerCards, playerUpSuites, nextPlayerSuites); + } else { // didn't guess correctly + fishedCard = drawCard(playerUpCards); + message = createMessage(playerUp, stolenCards, cardChoice, fishedCard); + if (fishedCard.getRank().equals(cardChoice)) { // drew a helpful card + //scan and get another turn + scanForSuites(playerUpCards, playerUpSuites, cardChoice); + turn(playerUp, nextPlayer, playerUpCards, nextPlayerCards, playerUpSuites, nextPlayerSuites); + } else { // did not draw + if (scanForSuites(playerUpCards, playerUpSuites, fishedCard.getRank())) { // ...got a suite from it, though + // go again + turn(playerUp, nextPlayer, playerUpCards, nextPlayerCards, playerUpSuites, nextPlayerSuites); + } else { // everything failed + // opponent's turn + turn(nextPlayer, playerUp, nextPlayerCards, playerUpCards, nextPlayerSuites, playerUpSuites); + } + } + } + } else { + fishMusic.stop(); + } + } + public GoFishPlayer checkForWin(GoFishPlayer playerUp, GoFishPlayer nextPlayer, CardSet playerUpSuites, CardSet nextPlayerSuites) { + + if (playerUpSuites.size() >= 7) { + return playerUp; + } else if (nextPlayerSuites.size() >= 7) { + console.printWithDelays(nextPlayer.getPlayer().getFirstName() + " IS THE WINNER!!!!!!!!! \n"); + return nextPlayer; + } else { + return null; + } + } + + public void announceWinner(GoFishPlayer winner) { + if (null != winner) { + console.printWithDelays(winner.getPlayer().getFirstName() + " IS THE WINNER!!!!!!!!! \n"); + endChoice(); + } + } + @Override + public void endChoice() { + //implements menu whether you want to quit or go again + + String endChoiceInput = console.getInput(("\n[DEALER]: You have finished this Go Fish Game.\n[DEALER]: Would you like to play again? (Y/N)\n")); + + if (endChoiceInput.toUpperCase().equals("N")) { + console.printWithDelays("\n[DEALER]: Enjoy the rest of your stay!!\n"); + console.sleep(1500); + + fishMusic.stop(); + + //also, return to the main menu + } else if (endChoiceInput.toUpperCase().equals("Y")) { + console.clearScreen(); + startPlay(); + + } else { + console.println("(That's not a valid selection. Please choose again.)"); + endChoice(); + } + } + + public void resetGame() { + this.playersCards = new CardSet(0); + this.opponentsCards = new CardSet(0); + this.playerSuites = new CardSet(0); + this.opponentSuites = new CardSet(0); + this.shoe = new CardSet(1); + } + + public String getName() { + return name; + } + + public GoFishPlayer getPlayer() { + return player; + } + + public GoFishNPC getOpponent() { + return opponent; + } + + public String createMessage(GoFishPlayer playerUp, ArrayList stolenCards, String cardChoice, Card fishedCard) { + String msg = ""; + if (fishedCard != null) { + if (playerUp instanceof GoFishNPC) { + msg = "*******************************************************************\n" + playerUp.getPlayer().getFirstName() + " Asked for " + cardChoice + ". Drew a card."; + } else { + msg = "*******************************************************************\n" + playerUp.getPlayer().getFirstName() + " Asked for " + cardChoice + ". Drew " + fishedCard.toString(); + } + } else { + msg = "*******************************************************************\n" + playerUp.getPlayer().getFirstName() + " Asked for " + cardChoice + ". Received " + stolenCards.size(); + } + + return msg; + } + + public CardSet getPlayersCards() { + return playersCards; + } + + public CardSet getOpponentsCards() { + return opponentsCards; + } + + public CardSet getPlayerSuites() { + return playerSuites; + } + + public CardSet getOpponentSuites() { + return opponentSuites; + } + + public void displayStatus() { + goTitleScreen(); + playersCards.sort(); + playerSuites.sort(); + console.println(displayOpponentHands()); + console.println(displayOpponentSuites()); + console.println(message); + console.println(displayPlayerSuites()); + console.println(displayPlayerHands()); + } + + public String displayPreviousTurn(){ + if (actingPlayer != null){ + return "*******************************************************************\n"+ actingPlayer + " Asked for " + "" + ". Received " + stolenCards.size(); + } + return "GO FISH!"; + } + + public String displayPlayerSuites() { + return "************************* PLAYER'S SUITES *************************\n" + playerSuites.toASCIISuite() + "\n"; + } + + public String displayPlayerHands() { + return "************************** PLAYER'S HAND **************************\n" + playersCards.toASCII() + "\n"; + } + + public String displayOpponentHands() { + return "************************* OPPONENT'S HAND *************************\n" + opponentsCards.toASCIIBlank() + "\n"; + } + + public String displayOpponentSuites() { + return "************************ OPPONENT'S SUITES ************************\n" + opponentSuites.toASCIISuite() + "\n"; + } + + public String goTitleScreen() { + console.println("\n >===> >=> \n" + + " >> >=> >> >> >=> \n" + + ">=> >=> >=>> >> >===> >=> \n" + + ">=> >=> >=> >=> >=> >=> >=>>=> \n" + + ">=> >===> >=> >=> >=> >=> >==> >=> >=> \n" + + " >=> >> >=> >=> >=> >=> >=> >> >=> \n" + + " >====> >=> >=> >=> >=>>=> >=> >=> \n" + + " \n"); + return "GO FISH!"; + } +} \ No newline at end of file diff --git a/src/main/java/io/zipcoder/casino/GoFish/GoFishNPC.java b/src/main/java/io/zipcoder/casino/GoFish/GoFishNPC.java new file mode 100644 index 000000000..3d711d8a9 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/GoFish/GoFishNPC.java @@ -0,0 +1,22 @@ +package io.zipcoder.casino.GoFish; + +import io.zipcoder.casino.Card; +import io.zipcoder.casino.CardSet; +import io.zipcoder.casino.Player; + +import java.util.ArrayList; +import java.util.Random; + +public class GoFishNPC extends GoFishPlayer{ + + public GoFishNPC (Player opponent) { + super(opponent); + } + + public String chooseCard(CardSet hand) { + Random rng = new Random(); + ArrayList cards = hand.getCards(); + Card chosenCard = cards.get(rng.nextInt(cards.size())); + return chosenCard.getRank(); + } +} diff --git a/src/main/java/io/zipcoder/casino/GoFish/GoFishPlayer.java b/src/main/java/io/zipcoder/casino/GoFish/GoFishPlayer.java new file mode 100644 index 000000000..635649007 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/GoFish/GoFishPlayer.java @@ -0,0 +1,39 @@ +package io.zipcoder.casino.GoFish; + +import io.zipcoder.casino.Card; +import io.zipcoder.casino.CardSet; +import io.zipcoder.casino.Player; +import io.zipcoder.casino.utilities.Console; + +import java.util.ArrayList; + +public class GoFishPlayer { + + private Player player; + private Console console = new Console(System.in, System.out); + + public GoFishPlayer(Player player){ + this.player = player; + + } + + public Player getPlayer() { + return player; + } + + public String chooseCard(CardSet hand) { + ArrayList ranks = new ArrayList(); + for (Card card : hand.getCards()) { + ranks.add(card.getRank()); + } + String input = ""; + while (true) { + input = console.getCardRankInput(""); + if (ranks.contains(input) || input.equals("N")) { + return input; + } + } + } + + +} diff --git a/src/main/java/io/zipcoder/casino/Interfaces/GamblingGame.java b/src/main/java/io/zipcoder/casino/Interfaces/GamblingGame.java new file mode 100644 index 000000000..3c6377b03 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Interfaces/GamblingGame.java @@ -0,0 +1,11 @@ +package io.zipcoder.casino.Interfaces; + +import io.zipcoder.casino.Player; + +public interface GamblingGame { + + boolean wager(double amount, Player player); + + void payOut(double amount, Player player); + +} diff --git a/src/main/java/io/zipcoder/casino/Interfaces/GamblingPlayer.java b/src/main/java/io/zipcoder/casino/Interfaces/GamblingPlayer.java new file mode 100644 index 000000000..fd191305f --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Interfaces/GamblingPlayer.java @@ -0,0 +1,5 @@ +package io.zipcoder.casino.Interfaces; + +public interface GamblingPlayer { + +} diff --git a/src/main/java/io/zipcoder/casino/Interfaces/Game.java b/src/main/java/io/zipcoder/casino/Interfaces/Game.java new file mode 100644 index 000000000..414dd2239 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Interfaces/Game.java @@ -0,0 +1,11 @@ +package io.zipcoder.casino.Interfaces; + +public interface Game { + + void startPlay() throws InterruptedException; + + void endChoice() throws InterruptedException; + + void roundOfPlay() throws InterruptedException; + +} diff --git a/src/main/java/io/zipcoder/casino/Interfaces/Menu.java b/src/main/java/io/zipcoder/casino/Interfaces/Menu.java new file mode 100644 index 000000000..6afc0c7e8 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Interfaces/Menu.java @@ -0,0 +1,11 @@ +package io.zipcoder.casino.Interfaces; + +public interface Menu { + + void displayMenu(); + + void handleChoice(int choice); + + String getName (); + +} diff --git a/src/main/java/io/zipcoder/casino/Menus/BlackjackMenu.java b/src/main/java/io/zipcoder/casino/Menus/BlackjackMenu.java new file mode 100644 index 000000000..00455cfcc --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Menus/BlackjackMenu.java @@ -0,0 +1,92 @@ +package io.zipcoder.casino.Menus; + +import io.zipcoder.casino.Blackjack.BlackjackGame; +import io.zipcoder.casino.Interfaces.Menu; +import io.zipcoder.casino.utilities.Console; + +public class BlackjackMenu implements Menu { + + private Console console; + private String name = "Blackjack Menu"; + private BlackjackGame blackjackGame; + + public BlackjackMenu(BlackjackGame blackjackGame) { + this.console = new Console (System.in, System.out); + this.blackjackGame = blackjackGame; + } + + @Override + public String getName() { + return name; + } + + @Override + public void displayMenu() { + + + console.clearScreen(); + // temporary + console.println(" .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. \n" + + "| .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. |\n" + + "| | ______ | || | _____ | || | __ | || | ______ | || | ___ ____ | || | _____ | || | __ | || | ______ | || | ___ ____ | |\n" + + "| | |_ _ \\ | || | |_ _| | || | / \\ | || | .' ___ | | || | |_ ||_ _| | || | |_ _| | || | / \\ | || | .' ___ | | || | |_ ||_ _| | |\n" + + "| | | |_) | | || | | | | || | / /\\ \\ | || | / .' \\_| | || | | |_/ / | || | | | | || | / /\\ \\ | || | / .' \\_| | || | | |_/ / | |\n" + + "| | | __'. | || | | | _ | || | / ____ \\ | || | | | | || | | __'. | || | _ | | | || | / ____ \\ | || | | | | || | | __'. | |\n" + + "| | _| |__) | | || | _| |__/ | | || | _/ / \\ \\_ | || | \\ `.___.'\\ | || | _| | \\ \\_ | || | | |_' | | || | _/ / \\ \\_ | || | \\ `.___.'\\ | || | _| | \\ \\_ | |\n" + + "| | |_______/ | || | |________| | || ||____| |____|| || | `._____.' | || | |____||____| | || | `.___.' | || ||____| |____|| || | `._____.' | || | |____||____| | |\n" + + "| | | || | | || | | || | | || | | || | | || | | || | | || | | |\n" + + "| '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' |\n" + + " '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' \n"); + console.println("Choose table stakes:\n"); + console.println("1. $5 min / $25 max"); + console.println("2. $20 min / $100 max"); + console.println("3. $50 min / $250 max"); + console.println("4. Set custom stakes ($5 - $500)"); + console.println("5. Stand up / Go Back to Game menu" ); + handleChoice(console.menuChoice(5)); + } + + @Override + public void handleChoice(int choice) { + switch (choice) { + case 1: // low stakes + this.blackjackGame.setMinBet(5.00); + this.blackjackGame.setMaxBet(5*this.blackjackGame.getMinBet()); + break; + case 2: // med stakes + this.blackjackGame.setMinBet(20.00); + this.blackjackGame.setMaxBet(5*this.blackjackGame.getMinBet()); + break; + case 3: // max stakes + this.blackjackGame.setMinBet(50.00); + this.blackjackGame.setMaxBet(5*this.blackjackGame.getMinBet()); + break; + case 4: // custom stakes + this.blackjackGame.setMinBet(getStakes()); + this.blackjackGame.setMaxBet(5*this.blackjackGame.getMinBet()); + break; + case 5: + + } + if (this.blackjackGame.getMinBet() != 0.0) { + double minBet = this.blackjackGame.getMinBet(); + double maxBet = this.blackjackGame.getMaxBet(); + console.println(String.format("Minimum bet is %.2f; maximum bet is %.2f", minBet, maxBet)); + } + + } + + double getStakes() { + double minBet = console.getCurrency("Table stakes? "); + if (minBet >= 5.00 && minBet <= 500.00) { + return minBet; + } else if (minBet < 5.00) { + console.println("Tables have a $5.00 minimum"); + } else { + console.println("Tables have a $500.00 maximum"); + } + return getStakes(); + } + + +} diff --git a/src/main/java/io/zipcoder/casino/Menus/Casino.java b/src/main/java/io/zipcoder/casino/Menus/Casino.java new file mode 100644 index 000000000..4a7d8ef7c --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Menus/Casino.java @@ -0,0 +1,212 @@ +package io.zipcoder.casino.Menus; + + +import io.zipcoder.casino.Player; +import io.zipcoder.casino.utilities.Console; +import io.zipcoder.casino.Utility.Music; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class Casino { + + private static Console console = new Console(System.in, System.out); + + + public static void main(String[] args) { + + //Starts playing music! + Music introMusic = null; + try { + Music.filePath = "src/music/(Intro) City sound effect 1 - downtown.wav"; + introMusic = new Music(); + introMusic.play(); + } catch (Exception ex) { + console.println("Error with playing sound."); + ex.printStackTrace(); + } + + Casino.prologue(); + Player player = Casino.newPlayerDialogue(); + + MainMenu mainMenu = new MainMenu(player); + + //stops the sound effects + try { + introMusic.stop(); + } catch (Exception e) { + e.printStackTrace(); + } + + mainMenu.displayMenu(); + } + + + public static void prologue() { + Thread inputThread = new Thread(new Runnable() { + BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); + long startTime = System.currentTimeMillis(); + + @Override + public void run() { + while (true) { + try { + if (((System.currentTimeMillis() - startTime) < 5000 && in.ready())) { + in.read(); + break; + } + } catch (IOException e) { + e.printStackTrace(); + } + } + return; + } + }); + + inputThread.start(); + + String[] lines = new String[] { + "\nYou had a really long day at work and decide to take the edge off by visiting the local casino.\n", + "\"Maybe if I win some big bucks I'll get out of this boring job of mine,\" you think to yourself. \n", + "The same thought always crosses your mind when passing by the big neon sign embroidered with flashing poker chips.\n", + "But tonight is a little different... \n\n\n", + "Tonight you're feeling lucky. \uD83C\uDF40\n\n\n\n", + }; + + for (String line : lines) { + for (char letter : line.toCharArray()){ + if (inputThread.isAlive()) { + console.print(Character.toString(letter)); + console.sleep(20); + } + } + if (inputThread.isAlive()) { + console.sleep(1200); + } + } + + console.printWithDelays("------------------------------------------------------------------------------------------------------------------------------\n",5); + console.printWithDelays(" ,----,. \n" + + " ,' ,' | ,--. ,----.. \n" + + " ,' .' | ,----, ,----.. ,---, .--.--. ,---, ,--.'| / / \\ \n" + + " ,----.' .' .' .' \\ / / \\ ' .' \\ / / '. ,`--.' | ,--,: : | / . : \n" + + " | | .' ,----,' | | : : / ; '. | : /`. / | : : ,`--.'`| ' : . / ;. \\ \n" + + " : : |--, | : . ; . | ;. / : : \\ ; | |--` : | ' | : : | | . ; / ` ; \n" + + " : | ;.' \\ ; |.' / . ; /--` : | /\\ \\ | : ;_ | : | : | \\ | : ; | ; \\ ; | \n" + + " | | | `----'/ ; ; | ; | : ' ;. : \\ \\ `. ' ' ; | : ' '; | | : | ; | ' \n" + + " `----'.'\\ ; / ; / | : | | | ;/ \\ \\ `----. \\ | | | ' ' ;. ; . | ' ' ' : \n" + + " __ \\ . | ; / /-, . | '___ ' : | \\ \\ ,' __ \\ \\ | ' : ; | | | \\ | ' ; \\; / | \n" + + " / /\\/ / : / / /.`| ' ; : .'| | | ' '--' / /`--' / | | ' ' : | ; .' \\ \\ ', / \n" + + "/ ,,/ ',- . ___ ./__; : ' | '/ : | : : '--'. / ' : | | | '`--' ; : / \n" + + "\\ ''\\ ; / .\\ | : .' | : / | | ,' `--'---' ; |.' ' : | \\ \\ .' \n" + + " \\ \\ .' \\ ; | ; | .' \\ \\ .' `--'' '---' ; |.' `---` \n" + + " `--`-,-' `--\" `---' `---` '---' ",1); + console.printWithDelays("\n------------------------------------------------------------------------------------------------------------------------------\n",5); + } + + + public static Player newPlayerDialogue() { + + console.printWithDelays("\n" + "\n((You walk up to the entrance and get greeted by a tall, stocky man with a handlebar mustache))\n"); + + String firstName = console.getInput("\n[TELLER]: What's your first name?\n"); + String lastName = console.getInput("\n[TELLER]: What's your last name? \n"); + int age = console.getInteger("\n[TELLER]: How old are you? \n"); + return new Player(firstName, lastName, age, 0.0); + } + + + public static void displayEnding(Player player) { + Music losingHorn = null; + Music tadaMusic = null; + Music neutral = null; + + if (player.getWinnings() < 0) { + //Sad ending: + try { + console.println(" _____\n" + + " /.---.\\\n" + + " |`````|\n" + + " \\ /\n" + + " `-.-' ____\n" + + " | /\\ .' /\\\n" + + " __|__ |K----; | |\n" + + " `-----` \\/ '.___\\/"); + Music.filePath = "src/music/(Sad ending) The Price is Right Losing Horn.wav"; + tadaMusic = new Music(); + tadaMusic.play(); + console.sleep(3000); + tadaMusic.stop(); + console.printWithDelays(String.format("\nDisgruntled and with your spirits broken, you hobble home with $%.2f less in your pocket.\nGuess tonight just wasn't the night.\n", Math.abs(player.getWinnings())),20,1200); + } catch (Exception ex) { + System.out.println("Error with playing sound."); + ex.printStackTrace(); + } + + + //Happy ending: + } else if (player.getWinnings() > 0) + try { + console.println(" ||====================================================================||\n" + + " ||//$\\\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\//$\\\\||\n" + + " ||(100)==================| FEDERAL RESERVE NOTE |================(100)||\n" + + " ||\\\\$// ~ '------========--------' \\\\$//||\n" + + " ||<< / /$\\ // ____ \\\\ \\ >>||\n" + + " ||>>| 12 //L\\\\ // ///..) \\\\ L38036134B 12 |<<||\n" + + " ||<<| \\\\ // || <|| >\\ || |>>||\n" + + " ||>>| \\$/ || $$ --/ || One Hundred |<<||\n" + + "||====================================================================||>||\n" + + "||//$\\\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\//$\\\\||<||\n" + + "||(100)==================| FEDERAL RESERVE NOTE |================(100)||>||\n" + + "||\\\\$// ~ '------========--------' \\\\$//||\\||\n" + + "||<< / /$\\ // ____ \\\\ \\ >>||)||\n" + + "||>>| 12 //L\\\\ // ///..) \\\\ L38036133B 12 |<<||/||\n" + + "||<<| \\\\ // || <|| >\\ || |>>||=||\n" + + "||>>| \\$/ || $$ --/ || One Hundred |<<||\n" + + "||<<| L38036133B *\\\\ |\\_/ //* series |>>||\n" + + "||>>| 12 *\\\\/___\\_//* 1989 |<<||\n" + + "||<<\\ Treasurer ______/Franklin\\________ Secretary 12 />>||\n" + + "||//$\\ ~|UNITED STATES OF AMERICA|~ /$\\\\||\n" + + "||(100)=================== ONE HUNDRED DOLLARS =================(100)||\n" + + "||\\\\$//\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\\\$//||\n" + + "||====================================================================||\n"); + Music.filePath = "src/music/(Happy ending) Windows 3.1 - Tada.wav"; + losingHorn = new Music(); + losingHorn.play(); + console.sleep(1500); + losingHorn.stop(); + console.printWithDelays((String.format("\nScore! You ended up bagging $%.2f in profit.\n", player.getWinnings()) + + "You head home with some pep in your step and even treat yourself to a scrumptious meal.\n"),20,1500); + } catch (Exception ex) { + System.out.println("Error with playing sound."); + ex.printStackTrace(); + + //Neutral ending + } + else { + try { + console.println("\n" + + " .------. \n" + + ".------. |A . | \n" + + "|A_ _ | .------; / \\ | \"YOU WIN SOME, \n" + + "|( \\/ )|-----. _ |(_,_) | YOU LOSE SOME.\"\n" + + "| \\ / | /\\ |( ) | I A| \n" + + "| \\/ A|/ \\ |_x_) |------' \n" + + "`-----+'\\ / | Y A| -GAYLE FORMAN \n" + + " | \\/ A|-----' \n" + + " `------' " + "\n" + "\n"); + Music.filePath = "src/music/(Happy ending) Windows 3.1 - Tada.wav"; + neutral = new Music(); + neutral.play(); + console.sleep(2000); + neutral.stop(); + console.printWithDelays("You left without winning or losing money, but hey at least you had fun!\n\n\n", 50, 3000); + } catch (Exception ex) { + System.out.println("Error with playing sound."); + ex.printStackTrace(); + } + } + System.exit(0); + } +} \ No newline at end of file diff --git a/src/main/java/io/zipcoder/casino/Menus/CrapsMenu.java b/src/main/java/io/zipcoder/casino/Menus/CrapsMenu.java new file mode 100644 index 000000000..ee14f54db --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Menus/CrapsMenu.java @@ -0,0 +1,46 @@ +package io.zipcoder.casino.Menus; + +import io.zipcoder.casino.Craps.CrapsGame; +import io.zipcoder.casino.Interfaces.Menu; +import io.zipcoder.casino.utilities.Console; + +public class CrapsMenu implements Menu { + + private Console console; + private String name = "Craps Menu"; + + + public CrapsMenu(CrapsGame crapsGame) { + this.console = new Console (System.in, System.out); + } + + @Override + public String getName() { + return name; + } + + @Override + public void displayMenu() { + console.clearScreen(); + + console.print(" \n" + + " ,o888888o. 8 888888888o. .8. 8 888888888o d888888o. \n" + + " 8888 `88. 8 8888 `88. .888. 8 8888 `88. .`8888:' `88. \n" + + ",8 8888 `8. 8 8888 `88 :88888. 8 8888 `88 8.`8888. Y8 \n" + + "88 8888 8 8888 ,88 . `88888. 8 8888 ,88 `8.`8888. \n" + + "88 8888 8 8888. ,88' .8. `88888. 8 8888. ,88' `8.`8888. \n" + + "88 8888 8 888888888P' .8`8. `88888. 8 888888888P' `8.`8888. \n" + + "88 8888 8 8888`8b .8' `8. `88888. 8 8888 `8.`8888. \n" + + "`8 8888 .8' 8 8888 `8b. .8' `8. `88888. 8 8888 8b `8.`8888. \n" + + " 8888 ,88' 8 8888 `8b. .888888888. `88888. 8 8888 `8b. ;8.`8888 \n" + + " `8888888P' 8 8888 `88. .8' `8. `88888. 8 8888 `Y8888P ,88P' \n\n\n"); + } + + @Override + public void handleChoice(int choice) { + + } + + + +} diff --git a/src/main/java/io/zipcoder/casino/Menus/GameMenu.java b/src/main/java/io/zipcoder/casino/Menus/GameMenu.java new file mode 100644 index 000000000..1b65e995f --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Menus/GameMenu.java @@ -0,0 +1,86 @@ +package io.zipcoder.casino.Menus; + +import io.zipcoder.casino.GameObject; +import io.zipcoder.casino.Interfaces.Menu; +import io.zipcoder.casino.Utility.Music; +import io.zipcoder.casino.Player; +import io.zipcoder.casino.Services.GameRepo; +import io.zipcoder.casino.utilities.Console; + +import java.util.HashMap; + +public class GameMenu implements Menu { + + //maps the choice number to the name of the game + private HashMap gameMap; + private GameRepo gameRepo; + private Console console; + private String name = "Game Menu"; + + Music mainMusic = null; + + public GameMenu(Player player) { + this.gameRepo = new GameRepo(player); + this.gameMap = gameRepo.getGamesMap(); + this.console = new Console(System.in, System.out); + } + + public HashMap getGameMap() { + return gameMap; + } + + public GameRepo getGameRepo() { + return gameRepo; + } + + @Override + public String getName() { + return name; + } + + @Override + public void displayMenu() { + + try { + Music.filePath = "src/music/(Menu) All of Me Instrumental.wav"; + mainMusic = new Music(); + mainMusic.play(); + } catch (Exception ex) { + System.out.println("Error playing sound."); + ex.printStackTrace(); + } + console.clearScreen(); + console.println("\n" + + " .........\n" + + " :~, * * ~,\n" + + " : ~, * * ~.\n" + + " : ~........~\n" + + " : *: : ~'~,\n" + + " : : : ~' * ~,\n" + + " ~* : * : ,~' * * ~,\n" + + " ~,: :.~,* * ,~ :\n" + + " ~:.........:: ~, * ,~ :\n" + + " : * ~,,~ * :\n" + + " :* * * : * :\n" + + " ~, * : * ,~\n" + + " ~, : ,~\n" + + " ~,:,~\n"); + + for (int gameNum : gameMap.keySet()) { + console.println(String.format("%d: %s", gameNum, ((GameObject) gameMap.get(gameNum)).getName())); + } + + handleChoice(console.menuChoice(gameMap.size())); + + displayMenu(); + } + + @Override + public void handleChoice(int choice) { + + mainMusic.stop(); + + gameMap.get(choice).startPlay(); + } + +} diff --git a/src/main/java/io/zipcoder/casino/Menus/GoFishMenu.java b/src/main/java/io/zipcoder/casino/Menus/GoFishMenu.java new file mode 100644 index 000000000..f9505612c --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Menus/GoFishMenu.java @@ -0,0 +1,33 @@ +package io.zipcoder.casino.Menus; + +import io.zipcoder.casino.Interfaces.Menu; +import io.zipcoder.casino.utilities.Console; + +public class GoFishMenu implements Menu { + + private Console console; + private String name = "Go Fish Menu"; + + public GoFishMenu() { + this.console = new Console (System.in, System.out); + + } + + @Override + public String getName() { + return name; + } + + @Override + public void displayMenu() { + + console.clearScreen(); + + + } + + @Override + public void handleChoice(int choice) { + + } +} diff --git a/src/main/java/io/zipcoder/casino/Menus/MainMenu.java b/src/main/java/io/zipcoder/casino/Menus/MainMenu.java new file mode 100644 index 000000000..59eba482e --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Menus/MainMenu.java @@ -0,0 +1,97 @@ +package io.zipcoder.casino.Menus; + + +import io.zipcoder.casino.Interfaces.Menu; + +import io.zipcoder.casino.Utility.Music; +import io.zipcoder.casino.Player; +import io.zipcoder.casino.utilities.Console; + +import java.util.HashMap; + + +public class MainMenu implements Menu { + + + private HashMap choiceMap; + private Player player; + private Console console; + private String name = "Main Menu"; + + Music mainMusic = null; + + public MainMenu(Player player) { + this.player = player; + this.console = new Console(System.in, System.out); + + choiceMap = new HashMap(); + int count = 0; + choiceMap.put(++count, new GameMenu(this.player)); + choiceMap.put(++count, new TellerMenu(this.player)); + choiceMap.put(++count, new NullMenu(this.player)); + } + + public static void main(String[] args) { + Player player = new Player("Herb", "Tarlek", 45, 0.00); + MainMenu mainMenu = new MainMenu(player); + mainMenu.displayMenu(); + } + + @Override + public void displayMenu() { + console.clearScreen(); + + console.println(" .======================================.\n" + + " | ___ ___ ___ _ _ _ |\n" + + " | \\_/ \\_/ \\_/ C|||C|||C||| |-| |-| |-| |\n" + + " | _|_ _|_ _|_ ||| ||| ||| |_| |_| |_| |\n" + + " '===================================== ,sSSSs\n" + + " THE MILL'S WATERING HOLE SSSS \"(\n" + + " .:. SSS@ =/ \\~/\n" + + " C|||' SSSS_(_ _Y_\n" + + " ___|||______________________________SS/ ) ) /.-\n" + + " [____________________________________] \\ /\\//\n" + + " | ____ ____ ____ ____ | \\|==(\\_/\n" + + " | (____) (____) (____) (____) | (/ ;\n" + + " | | | | | | | | | | |____|\n" + + " | | | | | | | | | | \\ |\\\n" + + " | | | | | | | | | | ) ) )\n" + + " | |____| |____| |____| |____| | ( |/\n" + + " | I====I I====I I====I I====I | /\\ |\n" + + " | | | | | | | | | /.(=\\\n" + + " Y\\_\\" + "\n" + "\n"); + try { + Music.filePath = "src/music/(Menu) All of Me Instrumental.wav"; + mainMusic = new Music(); + mainMusic.play(); + } catch (Exception ex) { + System.out.println("Error with playing sound."); + ex.printStackTrace(); + } + + for (int gameNum : choiceMap.keySet()) { + console.println(String.format("%d: %s", gameNum, (choiceMap.get(gameNum)).getName())); + } + + handleChoice(console.menuChoice(this.choiceMap.size())); + + + } + + @Override + public String getName() { + return name; + } + + @Override + public void handleChoice(int choice) { + try { + mainMusic.stop(); + } catch (Exception e) { + e.printStackTrace(); + } + choiceMap.get(choice).displayMenu(); + displayMenu(); + } +} + diff --git a/src/main/java/io/zipcoder/casino/Menus/NullGame.java b/src/main/java/io/zipcoder/casino/Menus/NullGame.java new file mode 100644 index 000000000..2814c7e26 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Menus/NullGame.java @@ -0,0 +1,38 @@ +package io.zipcoder.casino.Menus; + +import io.zipcoder.casino.CardGame; +import io.zipcoder.casino.Interfaces.Game; +import io.zipcoder.casino.Player; + +import io.zipcoder.casino.utilities.Console; + + +public class NullGame extends CardGame implements Game { + + private String name = "Main Menu"; + private Console console = new Console(System.in, System.out); + private Player player; + + public NullGame(Player player) { + this.player = player; + } + + @Override + public String getName() { + return name; + } + + public void startPlay() { + MainMenu mainmenu = new MainMenu(player); + mainmenu.displayMenu(); + } + + public void roundOfPlay() { + + } + + public void endChoice() { + + } + +} diff --git a/src/main/java/io/zipcoder/casino/Menus/NullMenu.java b/src/main/java/io/zipcoder/casino/Menus/NullMenu.java new file mode 100644 index 000000000..5ec20b3ae --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Menus/NullMenu.java @@ -0,0 +1,33 @@ +package io.zipcoder.casino.Menus; + +import io.zipcoder.casino.Interfaces.Menu; +import io.zipcoder.casino.Player; +import io.zipcoder.casino.utilities.Console; + +public class NullMenu implements Menu { + + private String name = "Quit"; + private Console console = new Console(System.in, System.out); + private Player player; + + public NullMenu(Player player) { + this.player = player; + } + + @Override + public String getName() { + return name; + } + + @Override + public void displayMenu() { + console.clearScreen(); + Casino.displayEnding(player); + + } + + @Override + public void handleChoice(int choice) { + + } +} diff --git a/src/main/java/io/zipcoder/casino/Menus/RRMenu.java b/src/main/java/io/zipcoder/casino/Menus/RRMenu.java new file mode 100644 index 000000000..a4f5230ce --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Menus/RRMenu.java @@ -0,0 +1,81 @@ +package io.zipcoder.casino.Menus; + +import io.zipcoder.casino.DiceGame; +import io.zipcoder.casino.Interfaces.Menu; +import io.zipcoder.casino.RR.RRGame; + +import io.zipcoder.casino.utilities.Console; + + + + +public class RRMenu implements Menu { + private boolean play; + private Console console; + private String name = "Russian Roulette Dice Menu"; + private RRGame rrGame; + + + public RRMenu(RRGame rrGame) { + + this.console = new Console(System.in, System.out); + this.rrGame = rrGame; + + } + + public boolean isPlay() { + return play; + } + + @Override + public String getName() { + return name; + } + + + @Override + public void displayMenu() { + + console.clearScreen(); + + + console.println("██████╗ ██╗ ██╗███████╗███████╗██╗ █████╗ ███╗ ██╗ ██████╗ ██████╗ ██╗ ██╗██╗ ███████╗████████╗████████╗███████╗\n" + + "██╔══██╗██║ ██║██╔════╝██╔════╝██║██╔══██╗████╗ ██║ ██╔══██╗██╔═══██╗██║ ██║██║ ██╔════╝╚══██╔══╝╚══██╔══╝██╔════╝\n" + + "██████╔╝██║ ██║███████╗███████╗██║███████║██╔██╗ ██║ ██████╔╝██║ ██║██║ ██║██║ █████╗ ██║ ██║ █████╗ \n" + + "██╔══██╗██║ ██║╚════██║╚════██║██║██╔══██║██║╚██╗██║ ██╔══██╗██║ ██║██║ ██║██║ ██╔══╝ ██║ ██║ ██╔══╝ \n" + + "██║ ██║╚██████╔╝███████║███████║██║██║ ██║██║ ╚████║ ██║ ██║╚██████╔╝╚██████╔╝███████╗███████╗ ██║ ██║ ███████╗\n" + + "╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚══════╝╚═╝╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝╚══════╝ ╚═╝ ╚═╝ ╚══════╝\n" + + " \n"); + console.sleep(1000); + console.printWithDelays("Welcome To Russian Roulette!\n\n", 20, 1000); + console.printWithDelays("- First the House will roll a die\n", 20, 1000); + console.printWithDelays("- Your bet will be your ENTIRE balance\n", 20, 1000); + console.printWithDelays("- Next, you will roll a die:\n", 20, 1000); + console.printWithDelays("- If your roll DOES NOT match the House's roll, your balance is DOUBLED!\n", 20, 1000); + console.printWithDelays("- If your roll matches the house......You lose all your balance.\n\n", 20, 1000); + console.printWithDelays("Are you willing to risk it all to win it all?\n\n", 20, 2000); + + console.println(DiceGame.diceToASCII(3, 5, 2)); + console.println(rrGame.displayUserBalance()); + int choice = console.getInteger("(Press 1 to play or 2 to exit):\n\n"); + handleChoice(choice); + + } + + @Override + public void handleChoice(int choice) { + switch (choice) { + case 1: + play = true; + console.clearScreen(); + rrGame.roundOfPlay(); + + break; + + case 2: + play = false; + + } + + } +} diff --git a/src/main/java/io/zipcoder/casino/Menus/TellerMenu.java b/src/main/java/io/zipcoder/casino/Menus/TellerMenu.java new file mode 100644 index 000000000..70738dba5 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Menus/TellerMenu.java @@ -0,0 +1,143 @@ +package io.zipcoder.casino.Menus; + +import io.zipcoder.casino.Interfaces.Menu; +import io.zipcoder.casino.Player; +import io.zipcoder.casino.Services.GameServices; +import io.zipcoder.casino.utilities.Console; +import io.zipcoder.casino.Utility.Music; + +import java.util.concurrent.TimeUnit; + + +public class TellerMenu implements Menu { + + Music tellerMusic = null; + private Console console; + private Player player; + private String name = "Teller Menu"; + private GameServices gameServices = new GameServices(); + + public TellerMenu(Player player) { + this.player = player; + this.console = new Console(System.in, System.out); + } + + @Override + public String getName() { + return name; + } + + @Override + public void displayMenu() { + console.clearScreen(); + + //plays music! + try { + Music.filePath = "src/music/(Teller) Casino slot -SOUND EFFECTS.wav"; + tellerMusic = new Music(); + tellerMusic.play(); + } catch (Exception ex) { + System.out.println("Error with playing sound."); + ex.printStackTrace(); + } + console.println(" .-------.\n" + + " oO{-JACKPOT-}Oo\n" + + " .=============. __\n" + + " |[\uD83E\uDD5D] [\uD83E\uDD5D] [\uD83D\uDD14]| ( )\n" + + " |[\uD83C\uDF52] [\uD83C\uDF52] [\uD83C\uDF52]| ||\n" + + " |[\uD83D\uDCB0] [\uD83D\uDD14] [\uD83D\uDCB0]| ||\n" + + " | |__||\n" + + " | xxx ::::::: |---'\n" + + " | ooo ::::::: |\n" + + " | $$$ ::::::: |\n" + + " | |\n" + + " | __ === |\n" + + " |_____/__\\____|\n" + + " /###############\\\n" + + " /#################\\\n" + + " |###################|\n" +"\n" + "\n"); + + + console.printWithDelays("[TELLER]: What can I do for ya?\n\n",TimeUnit.MILLISECONDS, 50); + + // temporary + console.println("1. Deposit funds"); + console.println("2. Cash out / Go home"); + console.println("3. Back to lobby"); + console.println(String.format("\nCurrent balance: $%.2f", player.getBalance())); + + handleChoice(console.getInteger(3)); + } + + @Override + public void handleChoice(int choice) { + + switch (choice) { + case 1: + depositFunds(); + try { + tellerMusic.stop(); + } catch (Exception e) { + e.printStackTrace(); + } + break; + case 2: + cashOut(); + + try { + tellerMusic.stop(); + } catch (Exception e) { + e.printStackTrace(); + } + + console.clearScreen(); + Casino.displayEnding(this.player); + break; + case 3: + // let's nix this, get it to just fall through back into MM + MainMenu mainmenu = new MainMenu(this.player); + try { + tellerMusic.stop(); + } catch (Exception e) { + e.printStackTrace(); + } + + mainmenu.displayMenu(); + break; + } + } + + public void depositFunds() { + double funds = console.getCurrency("\n[TELLER]: How much are you depositing?\n"); + if (funds == 0.0) { + console.printWithDelays("\n[TELLER]: Quit wastin' my time, buddy\n",50); + } else if (funds > 10000.0) { + console.printWithDelays("\n[TELLER]: Whoa, jeez, OK: you just knock over a bank or something?\n",50); + gameServices.deposit(funds, this.player); + console.printWithDelays("\n[TELLER]: Good luck, fancy pants!\n",50); + } else if (funds <= 20.0){ + console.printWithDelays("\n[TELLER]: Wow, are you sure it's safe walkin' around with all that?\n",50); + gameServices.deposit(funds, this.player); + console.printWithDelays("[TELLER]: Don't spend it all in once place! \n(He chuckles and proceeds to help another customer) \n\n",50); + } else { + console.printWithDelays(String.format("\n[TELLER]: Depositing $%.2f\n",funds)); + console.printWithDelays(". . .", 750); + gameServices.deposit(funds, this.player); + console.printWithDelays("\n[TELLER]: Here you go! Good luck at the tables.\n",50); + } + + console.getInput("\n\n( Press Enter to continue )\n"); + } + + public Double cashOut () { + Double withdrawal = gameServices.withdraw(this.player); + if (withdrawal != null) { + this.player.setWinnings(withdrawal - this.player.getInitialBalance()); + return withdrawal; + } else { + return 0.0; + } + + } + +} diff --git a/src/main/java/io/zipcoder/casino/Player.java b/src/main/java/io/zipcoder/casino/Player.java new file mode 100644 index 000000000..0bc373167 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Player.java @@ -0,0 +1,71 @@ +package io.zipcoder.casino; + +import io.zipcoder.casino.Interfaces.GamblingPlayer; + +public class Player implements GamblingPlayer { + + private String firstName; + private String lastName; + private int age; + private double balance; + private double initialBalance; + private double winnings; + + public Player(String firstName, String lastName, int age, double balance) { + this.firstName = firstName; + this.lastName = lastName; + this.age = age; + this.balance = balance; + this.initialBalance = this.balance; + } + + public String getFirstName() { + return firstName; + } + + public String getLastName() { + return lastName; + } + + public int getAge() { + return age; + } + + public double getBalance() { + return balance; + } + + public double getInitialBalance() { + return initialBalance; + } + + public double getWinnings() { + return winnings; + } + + public void setWinnings(double winnings) { + this.winnings = winnings; + } + + public void setInitialBalance(double initialBalance) { + this.initialBalance = initialBalance; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public void setAge(int age) { + this.age = age; + } + + public void setBalance(double balance) { + this.balance = balance; + } + + +} diff --git a/src/main/java/io/zipcoder/casino/RR/RRGame.java b/src/main/java/io/zipcoder/casino/RR/RRGame.java new file mode 100644 index 000000000..9a8008113 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/RR/RRGame.java @@ -0,0 +1,231 @@ +package io.zipcoder.casino.RR; + +import io.zipcoder.casino.DiceGame; +import io.zipcoder.casino.Menus.RRMenu; +import io.zipcoder.casino.Player; +import io.zipcoder.casino.Services.GameServices; +import io.zipcoder.casino.utilities.Console; +import io.zipcoder.casino.Interfaces.Game; +import io.zipcoder.casino.Utility.Music; + +public class RRGame extends DiceGame implements Game { + + + public static void main(String[] args) throws InterruptedException { + Player rrPlayer = new Player("Grace", "Bunde", 23, 500); + RRGame rrGame = new RRGame(rrPlayer); + + rrGame.startPlay(); + } + + private Console console = new Console(System.in, System.out); + private String name = "Russian Dice Roulette"; + private Integer userDieNum = 0; + private GameServices gameServices = new GameServices(); + private Player player; + Music rouletteMusic = null; + Music bang = null; + Music elFin = null; + private Integer computersRoll; + + public Integer getUserDieNum() { + return userDieNum; + } + + public void setUserDieNum(Integer userDieNum) { + this.userDieNum = userDieNum; + } + + public Integer getComputersRoll() { + return computersRoll; + } + + public void setComputersRoll(Integer computersRoll) { + this.computersRoll = computersRoll; + } + + public RRGame(Player player) { + this.player = player; + } + + public String getName() { + return name; + } + + + @Override + public void startPlay() { + + try { + io.zipcoder.casino.Utility.Music.filePath = "src/music/(Roulette) Kirby Star Allies Music.wav"; + rouletteMusic = new io.zipcoder.casino.Utility.Music(); + rouletteMusic.play(); + } catch (Exception ex) { + System.out.println("Error with playing sound."); + ex.printStackTrace(); + } + + // store menu + RRMenu rrMenu = new RRMenu(this); + rrMenu.displayMenu(); + rouletteMusic.stop(); + } + + @Override + public void endChoice() { + //implements menu whether you want to quit or go again + + String endChoiceInput = console.getInput(("\n[DEALER]: You have finished this Russian Roulette Game.\n[DEALER]: Would you like to play again? (Y/N)\n")); + + if (endChoiceInput.toUpperCase().equals("N")) { + rouletteMusic.stop(); + + console.printWithDelays("\n[DEALER]: Have a good rest of your day.\n"); + console.sleep(1200); + + //also, return to the main menu + } else if (endChoiceInput.toUpperCase().equals("Y")) { + + console.clearScreen(); + roundOfPlay(); + + } else { + console.println("(That's not a valid selection. Please choose again.)"); + endChoice(); + } + + } + + @Override + public void roundOfPlay() { + console.println(displayUserBalance()); + computerRoll(); + console.println(houseRollDisplay(computersRoll)); + userRollsDice(); + console.println(userRollDisplay(userDieNum)); + if (userDieNum.equals(computersRoll)) { + + rouletteMusic.stop(); + + gameServices.wager(player.getBalance(), player); + console.println(printLosingMessage()); + console.sleep(2000); + console.clearScreen(); + + console.sleep(1500); + console.printWithDelays(printDealersLosingMessage(), 80); + console.printWithDelays(printPistol(), 2); + try { + io.zipcoder.casino.Utility.Music.filePath = "src/music/(bang) sound effect.wav"; + bang = new io.zipcoder.casino.Utility.Music(); + bang.play(); + } catch (Exception ex) { + System.out.println("Error with playing sound."); + ex.printStackTrace(); + } + console.sleep(1000); + + bang.stop(); + + console.sleep(1000); + + console.clearScreen(); + try { + io.zipcoder.casino.Utility.Music.filePath = "src/music/(el fin) Super Mario Bros. - Game Over Sound Effect.wav"; + elFin = new io.zipcoder.casino.Utility.Music(); + elFin.play(); + } catch (Exception ex) { + System.out.println("Error with playing sound."); + ex.printStackTrace(); + } + console.printWithDelays(printElFin(), 3); + console.sleep(3000); + + elFin.stop(); + + System.exit(0); + + } else { + gameServices.payOut(this.player.getBalance(), this.player); + console.println(displayWinnerBalance()); + console.sleep(1000); + endChoice(); + + + } + + } + + public Integer userRollsDice() { + console.getInput("\n(Press Enter to roll the die): \n"); + userDieNum = roll(); + return userDieNum; + } + + + public Integer computerRoll() { + computersRoll = roll(); + return computersRoll; + } + + public String houseRollDisplay(Integer computersRoll) { + return String.format("------------------------------------------------------\n\n** The House rolled %d **\n" + DiceGame.diceToASCII(computersRoll), computersRoll); + } + + public String userRollDisplay(Integer userDieNum) { + return (String.format("------------------------------------------------------\n** You rolled %d **\n\n" + DiceGame.diceToASCII(userDieNum), userDieNum)); + } + + public String displayUserBalance() { + return String.format("Your Current Balance Is %.2f", player.getBalance()); + } + + + public String displayWinnerBalance() { + return String.format("\n\nYou Won!!! Your Balance Is Now $%.2f\n", player.getBalance()); + } + + public String printElFin() { + String elFinMessage = " ,ggggggg, ,gggggggggggggg \n" + + " ,dP\"\"\"\"\"\"Y8b ,dPYb, dP\"\"\"\"\"\"88\"\"\"\"\"\" \n" + + " d8' a Y8 IP'`Yb Yb,_ 88 \n" + + " 88 \"Y8P' I8 8I `\"\" 88 gg \n" + + " `8baaaa I8 8' ggg88gggg \"\" \n" + + ",d8P\"\"\"\" I8 dP 88 8 gg ,ggg,,ggg, \n" + + "d8\" I8dP 88 88 ,8\" \"8P\" \"8, \n" + + "Y8, I8P gg, 88 88 I8 8I 8I \n" + + "`Yba,,_____, ,d8b,_ \"Yb,,8P _,88,_,dP 8I Yb,\n" + + " `\"Y8888888 8P'\"Y88 \"Y8P' 8P\"\"Y88P' 8I `Y8\n\n\n\n"; + return elFinMessage; + } + + public String printPistol() { + String pistol = " \n\n\n" + + " ) /=>\n" + + " ( +____________________/\\/\\___ / /|\n" + + " .''._____________'._____ / /|/\\\n" + + " : () : :\\ ----\\| \\ )\n" + + " '..'______________.'0|----| \\\n" + + " 0_0/____/ \\\n" + + " |---- /----\\\n" + + " || -\\\\ --| \\\n" + + " || || ||\\ \\\n" + + " \\\\____// '| \\\n" + + " Bang! .'/ |\n" + + " .:/ |\n" + + " :/_________|"; + return pistol; + } + + public String printLosingMessage() { + String losingMessage = "\nYou Lost!!!"; + return losingMessage; + } + + public String printDealersLosingMessage () { + String dealersLosingMesage = "[DEALER]: Don't you know how Russian Roulette works?\n\n"; + return dealersLosingMesage; + } +} + + diff --git a/src/main/java/io/zipcoder/casino/Services/GameRepo.java b/src/main/java/io/zipcoder/casino/Services/GameRepo.java new file mode 100644 index 000000000..96bce6053 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Services/GameRepo.java @@ -0,0 +1,42 @@ +package io.zipcoder.casino.Services; + +import io.zipcoder.casino.Blackjack.BlackjackGame; +import io.zipcoder.casino.Craps.CrapsGame; +import io.zipcoder.casino.GoFish.GoFishGame; +import io.zipcoder.casino.GameObject; +import io.zipcoder.casino.Menus.NullGame; +import io.zipcoder.casino.Player; +import io.zipcoder.casino.RR.RRGame; +; +import java.util.HashMap; + +public class GameRepo { + + public static final int NUM_ADULT_GAMES = 3; + public static final int NUM_KID_GAMES = 1; + private HashMap gamesMap; + private Player player; + + public GameRepo(Player player) { + int counter = 1; + this.gamesMap = new HashMap(); + this.gamesMap.put(counter,new GoFishGame(player)); + this.player = player; + counter++; + if (this.player.getAge() >= 21) { + this.gamesMap.put(counter,new BlackjackGame(0.0, 0.0, player)); + counter++; + this.gamesMap.put(counter,new CrapsGame(10.0, 500.0, player)); + counter++; + this.gamesMap.put(counter,new RRGame(player)); + counter++; + } + this.gamesMap.put(counter, new NullGame(player)); + + } + + public HashMap getGamesMap() { + return this.gamesMap; + } + +} diff --git a/src/main/java/io/zipcoder/casino/Services/GameServices.java b/src/main/java/io/zipcoder/casino/Services/GameServices.java new file mode 100644 index 000000000..5e7a7e8a9 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Services/GameServices.java @@ -0,0 +1,39 @@ +package io.zipcoder.casino.Services; + +import io.zipcoder.casino.Interfaces.GamblingGame; +import io.zipcoder.casino.Player; + +public class GameServices implements GamblingGame { + + // need to instantiate this in each game. Call it via gameServices.wager(), etc. + + public boolean wager(double amount, Player player) { + double balance = player.getBalance(); + if (amount > balance) { + return false; + } else { + player.setBalance(balance - amount); + player.setWinnings(player.getBalance() - player.getInitialBalance()); + return true; + } + } + + public void payOut(double amount, Player player) { + player.setBalance(player.getBalance() + amount); + player.setWinnings(player.getBalance() - player.getInitialBalance()); + } + + public void deposit(double amount, Player player) { + payOut(amount, player); + player.setInitialBalance(player.getInitialBalance() + amount); + } + + public Double withdraw(Player player) { + double withdrawal = player.getBalance(); + if (wager(player.getBalance(), player)) { + return withdrawal; + } else { + return null; + } + } +} diff --git a/src/main/java/io/zipcoder/casino/Utilities/Console.java b/src/main/java/io/zipcoder/casino/Utilities/Console.java new file mode 100644 index 000000000..25ad2664c --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Utilities/Console.java @@ -0,0 +1,308 @@ +package io.zipcoder.casino.utilities; + + +import org.apache.commons.lang3.StringUtils; + +import java.io.InputStream; +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Scanner; +import java.util.concurrent.TimeUnit; + +/** + * You are advised against modifying this class. + */ +public final class Console { + private final Scanner input; + private final PrintStream output; + static final int DEFAULT_CASINO_DELAY = 20; + + public Console(InputStream in, PrintStream out) { + this.input = new Scanner(in); + this.output = out; + } + + public String getStringInput(String prompt, Object... args) { + println(prompt, args); + return input.nextLine(); + } + + public boolean cardCheck (String input) { + ArrayList choices = new ArrayList(Arrays.asList(new String[] {"2","3","4","5","6","7","8","9","10","J","Q","K","A"})); + return choices.contains(input); + } + + public String getCardRankInput(String prompt) { + print(prompt); + String input = getInput("Choose a card to take (2-10,J,Q,K,A), or N to quit: ").toUpperCase(); + while (true) { + if (cardCheck(input) || input.equals("N")) break; + else { + printWithDelays("Invalid card rank\n"); + print(prompt); + input = getCardRankInput(""); + } + + } + return input; + } + + public void clearScreen() { + for (int i = 0; i <100; i++) { + println(" "); + } + } + + public void print(String output, Object... args) { + this.output.printf(output, args); + } + + public void println(String output, Object... args) { + print(output + "\n", args); + } + + public String getInput() { + print("> "); + + String input = this.input.nextLine(); //get input from user + + return input; + } + + public String getInput(String prompt) { + print(prompt); + + String input = this.input.nextLine(); //get input from user + + return input; + } + + + public Integer getInput(String[] options) throws InterruptedException { + + clearScreen(); + + int numOptions = options.length; + int numRows = (numOptions+1) >> 1; // this is how the cool kids divide by two + String output = ""; + + String[] rows = new String[numRows]; + + for (int i = 0; i < numRows; i++){ + rows[i] = String.format("%d | %-30s", 2*i+1, options[2*i]); + if (2*i + 1 < numRows) { + rows[i] += String.format("%30s | %d", options[2*i + 1], 2*(i+1)); + } + rows[i] += "\n"; + } + + for (int i = 0; i < numRows; i++) { + output += rows[i]; + } + + printWithDelays(output); + + return getInteger(numOptions); + + } + + public String getInput(String header, String[] options) throws InterruptedException { + + clearScreen(); + + int numOptions = options.length; + int numRows = (numOptions+1) >> 1; // this is how the cool kids divide by two + String output = StringUtils.center(header,86) + "\n\n"; + + String[] rows = new String[numRows]; + + for (int i = 0; i < numRows; i++){ + rows[i] = String.format("%d | %-40s", 2*i+1, options[2*i]); + if (2*i + 1 < numOptions) { + rows[i] += String.format("%40s | %d", options[2*i + 1], 2*(i+1)); + } + rows[i] += "\n"; + } + + for (int i = 0; i < numRows; i++) { + output += rows[i]; + } + + printWithDelays(output); + + return Integer.toString(getInteger(numOptions)); + + } + + Boolean integerCheck(String input) { + return input.matches("^\\d+$"); + } + + Boolean currencyCheck(String input) { + return input.matches("^[0-9]{1,3}(?:,?[0-9]{3})*(?:\\.[0-9]{2})?$"); + } + + public Double getCurrency() { + String input = getInput("$"); + while (true) { + if (currencyCheck(input)) break; + else { + printWithDelays("Enter a number"); + input = getInput("$"); + } + } + return Double.valueOf(input); + } + + public Double getCurrency(String prompt) { + print(prompt); + String input = getInput("$"); + while (true) { + if (currencyCheck(input)) break; + else { + printWithDelays("Enter a valid number"); + print(prompt); + input = getInput("$"); + } + } + return Double.valueOf(input); + } + + public Double getCurrencyOrEnter(String prompt) { + print(prompt); + String input = getInput("$"); + while (true) { + if (currencyCheck(input)) { + break; + } else if (input.equals("")) { + return null; + } else { + printWithDelays("Enter a valid number"); + print(prompt); + input = getInput("$"); + } + } + return Double.valueOf(input); + } + + public Double getCurrency(String prompt, double min, double max) { + print(prompt); + String input = getInput("$"); + while (true) { + if (input.equals("")) { + return null; + } + if (currencyCheck(input)) { + double amount = Double.parseDouble(input); + if (amount >= min && amount <= max) { + break; + } else { + printWithDelays(String.format("Enter a number between %.2f and %.2f", min, max)); + print(prompt); + input = getInput("$"); + } + } + else { + printWithDelays("Enter a valid number"); + print(prompt); + input = getInput("$"); + } + } + return Double.valueOf(input); + } + + public Integer getInteger() { + String input = getInput(); + while (true) { + if (integerCheck(input)) break; + else { + printWithDelays("Enter a number"); + input = getInput(); + } + } + return Integer.valueOf(input); + } + + public Integer getInteger(String prompt) { + String input = getInput(prompt); + while (true) { + if (integerCheck(input)) break; + else { + printWithDelays("Enter a number."); + input = getInput(prompt); + } + } + return Integer.valueOf(input); + } + + public Integer getInteger(int max) { + String input = getInput(); + if (input.length() > 0){ + input = input.substring(0,1); + } + while (true) { + if (integerCheck(input)) { + if (Integer.parseInt(input) >= 1 && Integer.parseInt(input) <= max) { + break; + } else { + printWithDelays("Enter a number between 1 and " + Integer.toString(max)); + input = getInput(); + } + } + else { + printWithDelays("Enter a number"); + input = getInput(); + } + } + return Integer.valueOf(input); + } + + public Integer menuChoice(int max) { + print("\nMenu choice: \n"); + return getInteger(max); + } + + //Makes a type writer effect on screen + public void printWithDelays(String data, TimeUnit unit, long delay) { + try { + for (char ch : data.toCharArray()) { + print(Character.toString(ch)); + TimeUnit.MILLISECONDS.sleep(delay); + } + } catch (InterruptedException e){ + for (char ch : data.toCharArray()) { + print(Character.toString(ch)); + e.printStackTrace(); + } + } + } + + //Makes a type writer effect on screen + public void printWithDelays(String data, long delay) { + printWithDelays(data, TimeUnit.MILLISECONDS, delay); + } + + //Makes a type writer effect on screen + public void printWithDelays(String data, long delay, int pauseAfter) { + printWithDelays(data, delay); + sleep(pauseAfter); + } + + //Makes a type writer effect on screen + public void printWithDelays(String data) { + printWithDelays(data, Console.DEFAULT_CASINO_DELAY); + } + + public void sleep(int millis) { + try { + Thread.sleep(millis); + } catch (InterruptedException e) { + } + } + + public void getInput(String s, TimeUnit milliseconds, int i) { + } + +} + diff --git a/src/main/java/io/zipcoder/casino/Utilities/Music.java b/src/main/java/io/zipcoder/casino/Utilities/Music.java new file mode 100644 index 000000000..e3677b0ab --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Utilities/Music.java @@ -0,0 +1,62 @@ +package io.zipcoder.casino.Utility; + +import java.io.File; +import java.io.IOException; + +import javax.sound.sampled.AudioInputStream; +import javax.sound.sampled.AudioSystem; +import javax.sound.sampled.Clip; +import javax.sound.sampled.LineUnavailableException; +import javax.sound.sampled.UnsupportedAudioFileException; + +// Java program to play an Audio +// file using Clip Object +public class Music +{ + + // to store current position + Long currentFrame; + Clip clip; + // current status of clip + String status; + AudioInputStream audioInputStream; + public static String filePath; + + // constructor to initialize streams and clip + public Music() + throws UnsupportedAudioFileException, + IOException, LineUnavailableException + { + // create AudioInputStream object + audioInputStream = + AudioSystem.getAudioInputStream(new File(filePath).getAbsoluteFile()); + + // create clip reference + clip = AudioSystem.getClip(); + + // open audioInputStream to the clip + clip.open(audioInputStream); + + clip.loop(Clip.LOOP_CONTINUOUSLY); + } + + + // Method to play the audio + public void play() + { + //start the clip + clip.start(); + status = "play"; + } + + + // Method to stop the audio + public void stop() + { + currentFrame = 0L; + clip.stop(); + clip.close(); + } + +} + diff --git a/src/main/java/io/zipcoder/casino/utilities/Console.java b/src/main/java/io/zipcoder/casino/utilities/Console.java deleted file mode 100644 index ab896c956..000000000 --- a/src/main/java/io/zipcoder/casino/utilities/Console.java +++ /dev/null @@ -1,61 +0,0 @@ -package io.zipcoder.casino.utilities; - - -import java.io.InputStream; -import java.io.PrintStream; -import java.util.Scanner; - -/** - * You are advised against modifying this class. - */ -public final class Console { - private final Scanner input; - private final PrintStream output; - - public Console(InputStream in, PrintStream out) { - this.input = new Scanner(in); - this.output = out; - } - - public void print(String val, Object... args) { - output.format(val, args); - } - - public void println(String val, Object... vals) { - print(val + "\n", vals); - } - - public String getStringInput(String prompt, Object... args) { - println(prompt, args); - return input.nextLine(); - } - - public Double getDoubleInput(String prompt, Object... args) { - String stringInput = getStringInput(prompt, args); - try { - Double doubleInput = Double.parseDouble(stringInput); - return doubleInput; - } catch (NumberFormatException nfe) { // TODO - Eliminate recursive nature - println("[ %s ] is an invalid user input!", stringInput); - println("Try inputting a numeric value!"); - return getDoubleInput(prompt, args); - } - } - - public Long getLongInput(String prompt, Object... args) { - String stringInput = getStringInput(prompt, args); - try { - Long longInput = Long.parseLong(stringInput); - return longInput; - } catch (NumberFormatException nfe) { // TODO - Eliminate recursive nature - println("[ %s ] is an invalid user input!", stringInput); - println("Try inputting an integer value!"); - return getLongInput(prompt, args); - } - } - - public Integer getIntegerInput(String prompt, Object... args) { - return getLongInput(prompt, args).intValue(); - } -} - diff --git a/src/music/(BlackJack) Glide with me.wav b/src/music/(BlackJack) Glide with me.wav new file mode 100644 index 000000000..6219c53ba Binary files /dev/null and b/src/music/(BlackJack) Glide with me.wav differ diff --git a/src/music/(Craps) Amor maior - Higher Love.wav b/src/music/(Craps) Amor maior - Higher Love.wav new file mode 100644 index 000000000..45ea8c365 Binary files /dev/null and b/src/music/(Craps) Amor maior - Higher Love.wav differ diff --git a/src/music/(Go Fish) Underwater Theme GuitarMarimba Cover - Super Mario Bros. 1.wav b/src/music/(Go Fish) Underwater Theme GuitarMarimba Cover - Super Mario Bros. 1.wav new file mode 100644 index 000000000..22c861800 Binary files /dev/null and b/src/music/(Go Fish) Underwater Theme GuitarMarimba Cover - Super Mario Bros. 1.wav differ diff --git a/src/music/(Happy ending) Windows 3.1 - Tada.wav b/src/music/(Happy ending) Windows 3.1 - Tada.wav new file mode 100644 index 000000000..bf93d7d29 Binary files /dev/null and b/src/music/(Happy ending) Windows 3.1 - Tada.wav differ diff --git a/src/music/(Intro) City sound effect 1 - downtown.wav b/src/music/(Intro) City sound effect 1 - downtown.wav new file mode 100644 index 000000000..58f1fa950 Binary files /dev/null and b/src/music/(Intro) City sound effect 1 - downtown.wav differ diff --git a/src/music/(Menu) All of Me Instrumental.wav b/src/music/(Menu) All of Me Instrumental.wav new file mode 100644 index 000000000..7fb8c1568 Binary files /dev/null and b/src/music/(Menu) All of Me Instrumental.wav differ diff --git a/src/music/(Roulette) Kirby Star Allies Music.wav b/src/music/(Roulette) Kirby Star Allies Music.wav new file mode 100644 index 000000000..fabaa5238 Binary files /dev/null and b/src/music/(Roulette) Kirby Star Allies Music.wav differ diff --git a/src/music/(Sad ending) The Price is Right Losing Horn.wav b/src/music/(Sad ending) The Price is Right Losing Horn.wav new file mode 100644 index 000000000..ac4412357 Binary files /dev/null and b/src/music/(Sad ending) The Price is Right Losing Horn.wav differ diff --git a/src/music/(Teller) Casino slot -SOUND EFFECTS.wav b/src/music/(Teller) Casino slot -SOUND EFFECTS.wav new file mode 100644 index 000000000..295f8c1ce Binary files /dev/null and b/src/music/(Teller) Casino slot -SOUND EFFECTS.wav differ diff --git a/src/music/(bang) sound effect.wav b/src/music/(bang) sound effect.wav new file mode 100644 index 000000000..9cf4745af Binary files /dev/null and b/src/music/(bang) sound effect.wav differ diff --git a/src/music/(el fin) Super Mario Bros. - Game Over Sound Effect.wav b/src/music/(el fin) Super Mario Bros. - Game Over Sound Effect.wav new file mode 100644 index 000000000..919d9acef Binary files /dev/null and b/src/music/(el fin) Super Mario Bros. - Game Over Sound Effect.wav differ diff --git a/src/music/.DS_Store b/src/music/.DS_Store new file mode 100644 index 000000000..6ea651546 Binary files /dev/null and b/src/music/.DS_Store differ diff --git a/src/test/java/PlayerTest.java b/src/test/java/PlayerTest.java new file mode 100644 index 000000000..7e5f2769c --- /dev/null +++ b/src/test/java/PlayerTest.java @@ -0,0 +1,155 @@ +import io.zipcoder.casino.Player; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class PlayerTest { + + + + + + //Player constructor test + @Test + public void constructorTest (){ + // Given + String expectedFirstName = "David"; + String expectedLastName = "Trombello"; + int expectedAge = 37; + double expectedBalance = 450.0; + double expectedInitialBalance = 450.0; + double actualInitialBalance = expectedBalance; + + + // When + Player testPlayer = new Player (expectedFirstName, expectedLastName, expectedAge, expectedBalance); + + // Then + String actualFirstName = testPlayer.getFirstName(); + String actualLastName = testPlayer.getLastName(); + int actualAge = testPlayer.getAge(); + double actualBalance = testPlayer.getBalance(); + + + //Assertions + Assert.assertEquals(expectedFirstName, actualFirstName); + Assert.assertEquals(expectedLastName, actualLastName); + Assert.assertEquals(expectedAge, actualAge); + Assert.assertEquals(expectedBalance, actualBalance, 0.0000001); + Assert.assertEquals(expectedInitialBalance, actualInitialBalance, 0.0000001); + } + + + @Test + public void getFirstName() { + // Given + Player testPlayer = new Player("John", "Doe", 52, 327.0); + String expected = "John"; + + // Then + String actual = testPlayer.getFirstName(); + Assert.assertEquals(expected, actual); + } + + @Test + public void getLastName() { + // Given + Player testPlayer = new Player("John", "Doe", 52, 327.0); + String expected = "Doe"; + + // Then + String actual = testPlayer.getLastName(); + Assert.assertEquals(expected, actual); + } + + @Test + public void getAge() { + // Given + Player testPlayer = new Player("John", "Doe", 52, 327.0); + Integer expected = 52; + + // Then + Integer actual = testPlayer.getAge(); + Assert.assertEquals(expected, actual); + } + + @Test + public void getBalance() { + // Given + Player testPlayer = new Player("John", "Doe", 52, 327.0); + Double expected = 327.0; + + // Then + Double actual = testPlayer.getBalance(); + Assert.assertEquals(expected, actual); + } + + @Test + public void getWinnings() { + // Given + Player testPlayer = new Player("John", "Doe", 52, 327.0); + testPlayer.setWinnings(650.0); + Double expected = 650.0; + + // Then + Double actual = testPlayer.getWinnings(); + Assert.assertEquals(expected, actual); + } + + @Test + public void setFirstName() { + // Given + Player testPlayer = new Player("John", "Doe", 52, 327.0); + String expected = "Robert"; + + // When + testPlayer.setFirstName(expected); + + // Then + String actual = testPlayer.getFirstName(); + Assert.assertEquals(expected, actual); + } + + @Test + public void setLastName() { + // Given + Player testPlayer = new Player("John", "Doe", 52, 327.0); + String expected = "DelPriore"; + + // When + testPlayer.setLastName(expected); + + // Then + String actual = testPlayer.getLastName(); + Assert.assertEquals(expected, actual); + } + + @Test + public void setAge() { + // Given + Player testPlayer = new Player("John", "Doe", 52, 327.0); + Integer expected = 45; + + // When + testPlayer.setAge(expected); + + // Then + Integer actual = testPlayer.getAge(); + Assert.assertEquals(expected, actual); + } + + @Test + public void setBalance() { + // Given + Player testPlayer = new Player("John", "Doe", 52, 327.0); + Double expected = 435.0; + + // When + testPlayer.setBalance(expected); + + // Then + Double actual = testPlayer.getBalance(); + Assert.assertEquals(expected, actual); + } + +} diff --git a/src/test/java/io/zipcoder/casino/Blackjack/BlackjackGameTest.java b/src/test/java/io/zipcoder/casino/Blackjack/BlackjackGameTest.java new file mode 100644 index 000000000..0c278112b --- /dev/null +++ b/src/test/java/io/zipcoder/casino/Blackjack/BlackjackGameTest.java @@ -0,0 +1,221 @@ +package io.zipcoder.casino.Blackjack; + +import io.zipcoder.casino.Card; +import io.zipcoder.casino.CardSet; +import io.zipcoder.casino.Menus.BlackjackMenu; +import io.zipcoder.casino.Player; +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.util.ArrayList; + +import static org.junit.Assert.*; + +@RunWith(JUnitParamsRunner.class) +public class BlackjackGameTest { + + private BlackjackMenu blackjackMenu; + private BlackjackGame blackjackGame; + private Player player; + private BlackjackPlayer bjplayer; + private BlackjackNPCPlayer dealer; + + @Before + public void setUp() throws Exception { + player = new Player("William", "Adama", 45, 300.00); + blackjackGame = new BlackjackGame(0.0, 0.0, player); + blackjackMenu = new BlackjackMenu(blackjackGame); + bjplayer = blackjackGame.getPlayer(); + dealer = blackjackGame.getDealer(); + } + + @Test + @Parameters({"45.00,45.00", "0.00,0.00", "1000.00,1000.00", "23.00,23.00"}) + public void setMinBet(double input, double expected) { + blackjackGame.setMinBet(input); + Assert.assertEquals(expected, blackjackGame.getMinBet(), .01); + } + + @Test + @Parameters({"45.00,45.00", "0.00,0.00", "1000.00,1000.00", "23.00,23.00"}) + public void setMaxBet(double input, double expected) { + blackjackGame.setMaxBet(input); + Assert.assertEquals(expected, blackjackGame.getMaxBet(), .01); + } + + @Test + public void getName() { + Assert.assertEquals("Blackjack", blackjackGame.getName()); + } + + @Test + public void startPlay() { + } + + @Test + public void initialDealPlayerTest() { + blackjackGame.initialDeal(blackjackGame.getMinBet()); + ArrayList allHands = blackjackGame.getHands(); + BlackjackHand playerHand = allHands.get(0); + Assert.assertEquals(blackjackGame.getPlayer(), playerHand.getPlayer()); + ArrayList cards = playerHand.getCards().getCards(); + Assert.assertEquals(2, cards.size()); + Assert.assertNotEquals(cards.get(1), cards.get(0)); + System.out.println(cards.get(0).toString() + " " + cards.get(1).toString()); + } + @Test + public void initialDealDealerTest() { + blackjackGame.initialDeal(blackjackGame.getMinBet()); + ArrayList allHands = blackjackGame.getHands(); + BlackjackHand playerHand = allHands.get(1); + Assert.assertEquals(blackjackGame.getDealer(), playerHand.getPlayer()); + ArrayList cards = playerHand.getCards().getCards(); + Assert.assertEquals(2, cards.size()); + Assert.assertNotEquals(cards.get(1), cards.get(0)); + System.out.println(cards.get(0).toString() + " " + cards.get(1).toString()); + } + + @Test + public void roundOfPlay() { + } + + @Test + public void endChoice() { + } + + @Test + public void checkShoe() { + CardSet initialShoe = blackjackGame.getShoe(); + Assert.assertNull(initialShoe); + blackjackGame.checkShoe(); + CardSet shoe = blackjackGame.getShoe(); + Assert.assertEquals(52*blackjackGame.getNumDecks(),shoe.size()); + for (int i = 1; i < 26*blackjackGame.getNumDecks(); i++){ + shoe.removeFirstCard(); + shoe = blackjackGame.getShoe(); + Assert.assertEquals(52*blackjackGame.getNumDecks()-i,shoe.size()); + blackjackGame.checkShoe(); + } + shoe.removeFirstCard(); + shoe.removeFirstCard(); + blackjackGame.checkShoe(); + shoe = blackjackGame.getShoe(); + Assert.assertEquals(52*blackjackGame.getNumDecks(),shoe.size()); + } + + @Test + public void getNewShoe() { + CardSet shoe = blackjackGame.getNewShoe(); + Assert.assertEquals(52 * blackjackGame.getNumDecks(), shoe.size()); + CardSet shoe2 = blackjackGame.getNewShoe(); + Assert.assertFalse(shoe.getCards().get(0).strictEquals(shoe2.getCards().get(0)) + && shoe.getCards().get(1).strictEquals(shoe2.getCards().get(1)) + && shoe.getCards().get(2).strictEquals(shoe2.getCards().get(2))); + } + + @Test + public void calculateWinnings() { + } + + @Test + public void InitialDealWinningTest() { // bj push + blackjackGame.setMinBet(5.00); + blackjackGame.setMaxBet(25.00); + blackjackGame.initialDeal(blackjackGame.getMinBet()); + + CardSet pCards = new CardSet(0); + pCards.addCard(new Card("A","H")); + pCards.addCard(new Card("K","H")); + CardSet dCards = new CardSet(0); + dCards.addCard(new Card("A","H")); + dCards.addCard(new Card("K","H")); + + BlackjackHand playerHand = bjplayer.getHands().get(0); + playerHand.setCards(pCards); + BlackjackHand dealerHand = dealer.getHands().get(0); + dealerHand.setCards(dCards); + + Assert.assertEquals(5.0, blackjackGame.calculateWinnings(playerHand), .01); + Assert.assertEquals(true, blackjackGame.initialWinnerCheck()); + } + + @Test + public void InitialDealWinningTest1() { // bj win + blackjackGame.setMinBet(5.00); + blackjackGame.setMaxBet(25.00); + blackjackGame.initialDeal(blackjackGame.getMinBet()); + + CardSet pCards = new CardSet(0); + pCards.addCard(new Card("J","H")); + pCards.addCard(new Card("A","H")); + CardSet dCards = new CardSet(0); + dCards.addCard(new Card("Q","H")); + dCards.addCard(new Card("K","H")); + + BlackjackHand playerHand = bjplayer.getHands().get(0); + playerHand.setCards(pCards); + BlackjackHand dealerHand = dealer.getHands().get(0); + dealerHand.setCards(dCards); + + Assert.assertEquals(12.50, blackjackGame.calculateWinnings(playerHand), .01); + Assert.assertEquals(true, blackjackGame.initialWinnerCheck()); + } + + @Test + public void InitialDealWinningTest2() { // bj loss + blackjackGame.setMinBet(5.00); + blackjackGame.setMaxBet(25.00); + blackjackGame.initialDeal(blackjackGame.getMinBet()); + + CardSet pCards = new CardSet(0); + pCards.addCard(new Card("5","H")); + pCards.addCard(new Card("K","H")); + CardSet dCards = new CardSet(0); + dCards.addCard(new Card("10","H")); + dCards.addCard(new Card("A","H")); + + BlackjackHand playerHand = bjplayer.getHands().get(0); + playerHand.setCards(pCards); + BlackjackHand dealerHand = dealer.getHands().get(0); + dealerHand.setCards(dCards); + + Assert.assertEquals(0.0, blackjackGame.calculateWinnings(playerHand), .01); + Assert.assertEquals(true, blackjackGame.initialWinnerCheck()); + } + + @Test + public void InitialDealWinningTest3() { // normal + blackjackGame.setMinBet(5.00); + blackjackGame.setMaxBet(25.00); + blackjackGame.initialDeal(blackjackGame.getMinBet()); + + CardSet pCards = new CardSet(0); + pCards.addCard(new Card("A","H")); + pCards.addCard(new Card("5","H")); + CardSet dCards = new CardSet(0); + dCards.addCard(new Card("6","H")); + dCards.addCard(new Card("K","H")); + + BlackjackHand playerHand = bjplayer.getHands().get(0); + playerHand.setCards(pCards); + BlackjackHand dealerHand = dealer.getHands().get(0); + dealerHand.setCards(dCards); + + //Assert.assertEquals(5.0, blackjackGame.calculateWinnings(playerHand)); + Assert.assertEquals(false, blackjackGame.initialWinnerCheck()); + } + + @Test + public void displayTableTest() { + blackjackGame.setMinBet(5.00); + blackjackGame.setMaxBet(25.00); + blackjackGame.initialDeal(blackjackGame.getMinBet()); + + blackjackGame.displayTable(false); + + } +} \ No newline at end of file diff --git a/src/test/java/io/zipcoder/casino/Blackjack/BlackjackHandTest.java b/src/test/java/io/zipcoder/casino/Blackjack/BlackjackHandTest.java new file mode 100644 index 000000000..067f1ae47 --- /dev/null +++ b/src/test/java/io/zipcoder/casino/Blackjack/BlackjackHandTest.java @@ -0,0 +1,205 @@ +package io.zipcoder.casino.Blackjack; + +import io.zipcoder.casino.Card; +import io.zipcoder.casino.CardSet; +import io.zipcoder.casino.Menus.BlackjackMenu; +import io.zipcoder.casino.Player; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.Arrays; + +import static org.junit.Assert.*; + +public class BlackjackHandTest { + + private BlackjackGame blackjackGame; + private Player player; + private BlackjackHand hand; + private BlackjackPlayer bjp; + + @Before + public void setUp() throws Exception { + player = new Player("William", "Adama", 45, 300.00); + blackjackGame = new BlackjackGame(0.0, 0.0, player); + bjp = blackjackGame.getPlayer(); + blackjackGame.checkShoe(); + blackjackGame.initialDeal(blackjackGame.getMinBet()); + hand = bjp.getHands().get(0); + } + + @Test + public void getCards() { + Assert.assertEquals(2,hand.getCards().size()); + Card card1 = new Card("4","D"); + hand.addCard(card1); + Assert.assertEquals(3,(int) hand.getCards().size()); + } + + @Test + public void getBet() { + Assert.assertEquals(0.0,(int) hand.getBet(),.01); + hand.setBet(49.00); + Assert.assertEquals(49.00,(int) hand.getBet(),.01); + } + + @Test + public void getPlayer() { + Assert.assertEquals(player, hand.getPlayer().getPlayer()); + } + + @Test + public void clearTest() { + Assert.assertEquals(2,(int) hand.size()); + hand.clear(); + Assert.assertEquals(0,(int) hand.size()); + hand.clear(); + Assert.assertEquals(0,(int) hand.size()); + } + + @Test + public void addCardTest() { + Assert.assertEquals(2, (int) hand.size()); + Card card1 = new Card("4", "D"); + hand.addCard(card1); + Assert.assertEquals(3, (int) hand.size()); + } + + @Test + public void arraySumTest() { + ArrayList array = new ArrayList(Arrays.asList(2,4,10,11)); + Assert.assertEquals(27,hand.arraySum(array)); + array = new ArrayList(Arrays.asList(2,3,10,31,0,11)); + Assert.assertEquals(57,hand.arraySum(array)); + } + + @Test + public void mapCardsTest() { + CardSet cards = new CardSet(0); + cards.addCard(new Card("A","S")); + cards.addCard(new Card("2","H")); + cards.addCard(new Card("5","D")); + cards.addCard(new Card("K","C")); + + ArrayList actual = new ArrayList(); + actual = hand.mapCardValues(cards); + ArrayList expected = new ArrayList(Arrays.asList(2, 5, 10, 11)); + Assert.assertEquals(expected, actual); + } + + @Test + public void mapCardsTest2() { + CardSet cards = new CardSet(0); + cards.addCard(new Card("3","S")); + cards.addCard(new Card("Q","H")); + cards.addCard(new Card("J","D")); + cards.addCard(new Card("10","C")); + + ArrayList actual = new ArrayList(); + actual = hand.mapCardValues(cards); + ArrayList expected = new ArrayList(Arrays.asList(3,10,10,10)); + Assert.assertEquals(expected, actual); + } + + @Test + public void getValueTest() { + hand.clear(); + hand.addCard(new Card("3","S")); + hand.addCard(new Card("Q","H")); + hand.addCard(new Card("J","D")); + hand.addCard(new Card("10","C")); + + Assert.assertEquals(0,hand.getValue()); + } + + @Test + public void getValueTest2() { + hand.clear(); + hand.addCard(new Card("3","H")); + hand.addCard(new Card("5","D")); + hand.addCard(new Card("4","C")); + hand.addCard(new Card("A","S")); + + Assert.assertEquals(13,hand.getValue()); + } + + @Test + public void getValueTest3() { + hand.clear(); + hand.addCard(new Card("A","S")); + hand.addCard(new Card("K","H")); + + + Assert.assertEquals(21,hand.getValue()); + } + + @Test + public void getValueTest4() { + hand.clear(); + hand.addCard(new Card("2","S")); + hand.addCard(new Card("K","H")); + hand.addCard(new Card("5","D")); + hand.addCard(new Card("4","C")); + + Assert.assertEquals(21,hand.getValue()); + } + + @Test + public void getValueTest5() { + hand.clear(); + hand.addCard(new Card("A","S")); + hand.addCard(new Card("3","H")); + hand.addCard(new Card("K","D")); + hand.addCard(new Card("4","C")); + + Assert.assertEquals(18,hand.getValue()); + } + + @Test + public void getValueTest6() { + hand.clear(); + hand.addCard(new Card("3","H")); + hand.addCard(new Card("K","D")); + hand.addCard(new Card("4","C")); + + Assert.assertEquals(17,hand.getValue()); + } + + @Test + public void getValueTest7() { + hand.clear(); + + Assert.assertEquals(0,hand.getValue()); + } + + @Test + public void getValueTest8() { + hand.clear(); + hand.addCard(new Card("A","H")); + hand.addCard(new Card("A","D")); + + Assert.assertEquals(12,hand.getValue()); + } + + @Test + public void getValueTest9() { + hand.clear(); + for (int i = 0; i < 21; i++) { + hand.addCard(new Card("A", "H")); + } + + Assert.assertEquals(21,hand.getValue()); + } + + @Test + public void getValueTest10() { + hand.clear(); + for (int i = 0; i < 22; i++) { + hand.addCard(new Card("A", "H")); + } + + Assert.assertEquals(0,hand.getValue()); + } +} \ No newline at end of file diff --git a/src/test/java/io/zipcoder/casino/Blackjack/BlackjackPlayerTest.java b/src/test/java/io/zipcoder/casino/Blackjack/BlackjackPlayerTest.java new file mode 100644 index 000000000..ee28d21b2 --- /dev/null +++ b/src/test/java/io/zipcoder/casino/Blackjack/BlackjackPlayerTest.java @@ -0,0 +1,66 @@ +package io.zipcoder.casino.Blackjack; + +import io.zipcoder.casino.Player; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class BlackjackPlayerTest { + + private Player player; + private BlackjackPlayer blackjackPlayer; + + @Before + public void setUp() throws Exception { + player = new Player ("Steve", "Rondinaro", 56, 400.00); + blackjackPlayer = new BlackjackPlayer(player); + } + + @Test + public void getPlayerTest() { + Assert.assertEquals(player, blackjackPlayer.getPlayer()); + Assert.assertEquals(400.00, blackjackPlayer.getPlayer().getBalance(),.01); + } + + @Test + public void addHandTest1() { + BlackjackHand blackjackHand = new BlackjackHand(45.00, blackjackPlayer, null, null); + Assert.assertTrue(blackjackPlayer.getHands().size() == 0); + Assert.assertFalse(blackjackPlayer.getHands().contains(blackjackHand)); + blackjackPlayer.addHand(blackjackHand); + Assert.assertTrue(blackjackPlayer.getHands().size() == 1); + Assert.assertTrue(blackjackPlayer.getHands().contains(blackjackHand)); + } + + @Test + public void addHandTest2() { + BlackjackHand blackjackHand = new BlackjackHand(45.00, blackjackPlayer, null, null); + blackjackPlayer.addHand(blackjackHand); + BlackjackHand blackjackHand2 = new BlackjackHand(55.00, blackjackPlayer, null, null); + blackjackPlayer.addHand(blackjackHand2); + Assert.assertTrue(blackjackPlayer.getHands().size() == 2); + Assert.assertTrue(blackjackPlayer.getHands().contains(blackjackHand2)); + Assert.assertTrue(blackjackPlayer.getHands().contains(blackjackHand)); + } + + @Test + public void removeHandTest() { + BlackjackHand blackjackHand = new BlackjackHand(45.00, blackjackPlayer, null, null); + blackjackPlayer.addHand(blackjackHand); + BlackjackHand blackjackHand2 = new BlackjackHand(55.00, blackjackPlayer, null, null); + blackjackPlayer.addHand(blackjackHand2); + Assert.assertTrue(blackjackPlayer.getHands().size() == 2); + Assert.assertTrue(blackjackPlayer.getHands().contains(blackjackHand2)); + Assert.assertTrue(blackjackPlayer.getHands().contains(blackjackHand)); + blackjackPlayer.removeHand(blackjackHand); + Assert.assertTrue(blackjackPlayer.getHands().size() == 1); + Assert.assertTrue(blackjackPlayer.getHands().contains(blackjackHand2)); + Assert.assertFalse(blackjackPlayer.getHands().contains(blackjackHand)); + blackjackPlayer.removeHand(blackjackHand2); + Assert.assertTrue(blackjackPlayer.getHands().size() == 0); + Assert.assertFalse(blackjackPlayer.getHands().contains(blackjackHand2)); + Assert.assertFalse(blackjackPlayer.getHands().contains(blackjackHand)); + } +} \ No newline at end of file diff --git a/src/test/java/io/zipcoder/casino/CardSetTest.java b/src/test/java/io/zipcoder/casino/CardSetTest.java new file mode 100644 index 000000000..49167ef23 --- /dev/null +++ b/src/test/java/io/zipcoder/casino/CardSetTest.java @@ -0,0 +1,235 @@ +package io.zipcoder.casino; + +import io.zipcoder.casino.utilities.Console; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.Collections; + +public class CardSetTest { + + private CardSet empty; + private CardSet oneDeck; + private CardSet fiveDecks; + + @Before + public void setUp() throws Exception { + empty = new CardSet(0); + oneDeck = new CardSet(1); + fiveDecks = new CardSet(5); + } + + @Test + public void getCardsTest1() { + Assert.assertEquals(new ArrayList(),empty.getCards()); + } + @Test + public void getCardsTest2() { + Assert.assertEquals(52,oneDeck.getCards().size()); + } + @Test + public void getCardsTest3() { + Assert.assertEquals(260,fiveDecks.getCards().size()); + } + @Test + public void getCardsTest4() { + int count = 0; + for (Card card: oneDeck.getCards()) { + if (card.equals(new Card("A","C"))) { + count++; + } + } + Assert.assertEquals(4, count); + } + @Test + public void getCardsTest5() { + int count = 0; + for (Card card: fiveDecks.getCards()) { + if (card.equals(new Card("A","C"))) { + count++; + } + } + Assert.assertEquals(20, count); + } + @Test + public void getCardsTest6() { + int count = 0; + for (Card card: fiveDecks.getCards()) { + if (card.strictEquals(new Card("A","C"))) { + count++; + } + } + Assert.assertEquals(5, count); + } + + @Test + public void sizeTest1() { + Assert.assertEquals(0,empty.size()); + } + @Test + public void sizeTest2() { + Assert.assertEquals(52,oneDeck.size()); + } + @Test + public void sizeTest3() { + Assert.assertEquals(260,fiveDecks.size()); + } + + @Test + public void removeFirstCard() { + Assert.assertTrue(new Card("A","H").strictEquals(oneDeck.removeFirstCard())); + Assert.assertEquals(51,oneDeck.size()); + Assert.assertTrue(new Card("A","D").strictEquals(oneDeck.removeFirstCard())); + Assert.assertEquals(50,oneDeck.size()); + } + + @Test + public void removeCard() { + ArrayList foundCards = oneDeck.removeRank("K"); + for (Card card : foundCards) { + Assert.assertTrue(card.getRank() == "K"); + } + + Assert.assertTrue(4 == foundCards.size()); + Assert.assertEquals(48,oneDeck.size()); + Assert.assertTrue(0 == oneDeck.removeRank("K").size()); + Assert.assertEquals(48,oneDeck.size()); + + } + + @Test + public void addCard() { + oneDeck.addCard(new Card("K","C")); + Assert.assertTrue(oneDeck.removeRank("K").size() == 5); + Assert.assertEquals(48,oneDeck.size()); + Assert.assertTrue(oneDeck.removeRank("K").size() == 0); + Assert.assertEquals(48,oneDeck.size()); + + + } + + @Test + public void clearTest() { + Assert.assertEquals(52,oneDeck.size()); + oneDeck.clear(); + Assert.assertEquals(0,oneDeck.size()); + } + + @Test + public void clearTest2() { + Assert.assertEquals(0,empty.size()); + oneDeck.clear(); + Assert.assertEquals(0,empty.size()); + } + + @Test + public void addCard2() { + empty.addCard(new Card("A","D")); + empty.addCard(new Card("4","H")); + empty.addCard(new Card("7","S")); + empty.addCard(new Card("5","C")); + empty.addCard(new Card("2","D")); + Assert.assertEquals(5,empty.size()); + Assert.assertTrue(new Card("2","D").strictEquals(empty.removeFirstCard())); + Assert.assertTrue(new Card("5","C").strictEquals(empty.removeFirstCard())); + Assert.assertTrue(empty.removeRank("7").size() == 1); + Assert.assertTrue(new Card("4","H").strictEquals(empty.removeFirstCard())); + Assert.assertTrue(new Card("A","D").strictEquals(empty.removeFirstCard())); + Assert.assertTrue(null == empty.removeFirstCard()); + } + + @Test + public void sortTest() { + empty.addCard(new Card("A","D")); + empty.addCard(new Card("4","H")); + empty.addCard(new Card("7","S")); + empty.addCard(new Card("5","C")); + empty.addCard(new Card("2","D")); + + empty.sort(); + Assert.assertTrue(new Card("A","D").strictEquals(empty.removeFirstCard())); + Assert.assertTrue(new Card("7","S").strictEquals(empty.removeFirstCard())); + Assert.assertTrue(new Card("5","C").strictEquals(empty.removeFirstCard())); + Assert.assertTrue(new Card("4","H").strictEquals(empty.removeFirstCard())); + Assert.assertTrue(new Card("2","D").strictEquals(empty.removeFirstCard())); + } + + @Test + public void shuffleTest() { + Assert.assertTrue(new Card("2","S").strictEquals(fiveDecks.getCards().get(0)) + && new Card("2","C").strictEquals(fiveDecks.getCards().get(1)) + && new Card("2","D").strictEquals(fiveDecks.getCards().get(2)) + && new Card("2","H").strictEquals(fiveDecks.getCards().get(3))); + + fiveDecks.shuffle(); + Assert.assertFalse(new Card("2","S").strictEquals(fiveDecks.getCards().get(0)) + && new Card("2","C").strictEquals(fiveDecks.getCards().get(1)) + && new Card("2","D").strictEquals(fiveDecks.getCards().get(2)) + && new Card("2","H").strictEquals(fiveDecks.getCards().get(3))); + } + + @Test + public void sortandShuffleTest() { + ArrayList fiveDecksClone = (ArrayList) fiveDecks.getCards().clone(); + Collections.sort(fiveDecksClone); + fiveDecks.sort(); + Assert.assertTrue("one",fiveDecksClone.equals(fiveDecks.getCards())); + fiveDecks.shuffle(); + Assert.assertFalse("two",fiveDecksClone.equals(fiveDecks.getCards())); + fiveDecks.sort(); + // the card objects are in a different order, so we have to loop to test if they're isomorphic + for (int i = 0; i < fiveDecks.getCards().size(); i++) { + Assert.assertTrue(fiveDecks.getCards().get(i).equals(fiveDecksClone.get(i))); + } + } + + @Test + public void toASCIITest() { + CardSet cards = new CardSet(0); + cards.addCard(new Card("A","H")); + cards.addCard(new Card("K","D")); + cards.addCard(new Card("Q","S")); + cards.addCard(new Card("J","C")); + cards.addCard(new Card("10","H")); + cards.addCard(new Card("9","D")); + cards.addCard(new Card("8","S")); + cards.addCard(new Card("7","C")); + + Console console = new Console(System.in, System.out); + console.println(cards.toASCII()); + } + + @Test + public void toASCIISuiteTest() { + CardSet cards = new CardSet(0); + cards.addCard(new Card("A","H")); + cards.addCard(new Card("K","D")); + cards.addCard(new Card("Q","S")); + cards.addCard(new Card("J","C")); + cards.addCard(new Card("10","H")); + cards.addCard(new Card("9","D")); + cards.addCard(new Card("8","S")); + cards.addCard(new Card("7","C")); + + Console console = new Console(System.in, System.out); + console.println(cards.toASCIISuite()); + } + + @Test + public void toASCIIBlankTest() { + CardSet cards = new CardSet(0); + cards.addCard(new Card("A","H")); + cards.addCard(new Card("K","D")); + cards.addCard(new Card("Q","S")); + cards.addCard(new Card("J","C")); + cards.addCard(new Card("10","H")); + cards.addCard(new Card("9","D")); + cards.addCard(new Card("8","S")); + cards.addCard(new Card("7","C")); + + Console console = new Console(System.in, System.out); + console.println(cards.toASCIIBlank()); + } +} \ No newline at end of file diff --git a/src/test/java/io/zipcoder/casino/CardTest.java b/src/test/java/io/zipcoder/casino/CardTest.java new file mode 100644 index 000000000..64f278687 --- /dev/null +++ b/src/test/java/io/zipcoder/casino/CardTest.java @@ -0,0 +1,80 @@ +package io.zipcoder.casino; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; + +import static org.junit.Assert.*; + +public class CardTest { + + private Card card1; + + @Before + public void setUp() throws Exception { + card1 = new Card("7","H"); + } + + @Test + public void compareToTest() { + Assert.assertTrue(card1.compareTo(new Card("8","H")) == -1); + } + + @Test + public void compareToTest2() { + Assert.assertTrue(card1.compareTo(new Card("7","S")) == 1); + } + + @Test + public void compareToTest3() { + Assert.assertTrue(card1.compareTo(new Card("3","C")) == 1); + } + + @Test + public void compareToTest4() { + Assert.assertTrue(card1.compareTo(new Card("A","D")) == -1); + } + + @Test + public void compareToTest5() { + Assert.assertTrue(card1.compareTo(new Card("A","D")) == -1); + } + + @Test + public void testToString() { + Assert.assertEquals("7\u2666", new Card("7","D").toString()); + } + + @Test + public void testToString2() { + Assert.assertEquals("7\u2665", card1.toString()); + } + + @Test + public void testToString3() { + Assert.assertEquals("3\u2663", new Card("3","C").toString()); + } + + @Test + public void testToString4() { + Assert.assertEquals("7\u2660", new Card("7","S").toString()); + } + + @Test + public void sortToTestOrderingRulesTest() { + Card[] cards = new Card[] {card1, new Card("3","C"), new Card("7","S"), new Card("A","D"), new Card("K","S"), new Card("J","C"), new Card("Q","D")}; + Card[] expected = new Card[] {new Card("3","C"), new Card("7","S"), card1, new Card("J","C"), new Card("Q","D"), new Card("K","S"), new Card("A","D")}; + ArrayList cardAL = new ArrayList(Arrays.asList(cards)); + Collections.sort(cardAL); + + for (int i = 0; i < cards.length; i++) { + Assert.assertTrue(expected[i].compareTo(cardAL.get(i)) == 0); + } + + } + +} \ No newline at end of file diff --git a/src/test/java/io/zipcoder/casino/CasinoTest.java b/src/test/java/io/zipcoder/casino/CasinoTest.java deleted file mode 100644 index e92865236..000000000 --- a/src/test/java/io/zipcoder/casino/CasinoTest.java +++ /dev/null @@ -1,5 +0,0 @@ -package io.zipcoder.casino; - - -public class CasinoTest { -} diff --git a/src/test/java/io/zipcoder/casino/Craps/CrapsGameTest.java b/src/test/java/io/zipcoder/casino/Craps/CrapsGameTest.java new file mode 100644 index 000000000..becb8a5a0 --- /dev/null +++ b/src/test/java/io/zipcoder/casino/Craps/CrapsGameTest.java @@ -0,0 +1,335 @@ +package io.zipcoder.casino.Craps; + +import io.zipcoder.casino.DiceGame; +import io.zipcoder.casino.Menus.CrapsMenu; +import io.zipcoder.casino.Player; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class CrapsGameTest { + + private CrapsMenu crapsMenu; + private CrapsGame crapsGame; + private Player player; + private Double wager; + private Integer setThePointRoll; + private Integer currentRoll; + private Integer numRolls; + private Double winnings; + + @Before + public void setUp() throws Exception{ + //starting balance was $200, minus the wager of $50 + wager = 50.00; //note that for purposes of this test, this wager is taken out before the balance below + player = new Player("Zapp","Brannigan", 46,150); //reflects balance after wager + crapsGame = new CrapsGame(10.0, 50.0, player); + crapsMenu = new CrapsMenu(crapsGame); + + } + + @Test + public void getFirstNameTest(){ + String expected = "Zapp"; + String actual = player.getFirstName(); + Assert.assertEquals(expected, actual); + } + + @Test + public void getLastNameTest(){ + String expected = "Brannigan"; + String actual = player.getLastName(); + Assert.assertEquals(expected, actual); + } + + @Test + //tests whether win on first works on 7 + public void winOnFirstTest(){ + setThePointRoll = 7; + Assert.assertTrue(crapsGame.winOnFirst(setThePointRoll)); + } + + @Test + //tests whether win on first works on 8 + public void winOnFirstTest3(){ + setThePointRoll = 8; + Assert.assertFalse(crapsGame.winOnFirst(setThePointRoll)); + + } + + @Test + //tests whether win on first works on 11 + public void winOnFirstTest2(){ + setThePointRoll = 11; + Assert.assertTrue(crapsGame.winOnFirst(setThePointRoll)); + + } + + @Test + //tests whether lose on first works on 2 + public void loseOnFirstTest(){ + setThePointRoll = 2; + Assert.assertTrue(crapsGame.loseOnFirst(setThePointRoll)); + + } + + @Test + //tests whether lose on first works on 3 + public void loseOnFirstTest2(){ + setThePointRoll = 3; + Assert.assertTrue(crapsGame.loseOnFirst(setThePointRoll)); + + } + + @Test + //tests whether lose on first works on 12 + public void loseOnFirstTest3(){ + setThePointRoll = 12; + Assert.assertTrue(crapsGame.loseOnFirst(setThePointRoll)); + + } + + @Test + //tests whether lose on first works on 2 + public void loseOnFirstTest4() { + setThePointRoll = 8; + Assert.assertFalse(crapsGame.loseOnFirst(setThePointRoll)); + } + + @Test + //tests whether win on subsequent works if they win + public void winOnSubsequentTest(){ + setThePointRoll = 8; + currentRoll = 8; + Assert.assertTrue(crapsGame.winOnSubsequent(currentRoll, setThePointRoll)); + } + + @Test + //tests whether win on subsequent works if they win + public void winOnSubsequentTest2(){ + setThePointRoll = 8; + currentRoll = 5; + Assert.assertFalse(crapsGame.winOnSubsequent(currentRoll, setThePointRoll)); + } + + @Test + //tests whether win on subsequent works if they win + public void LoseOnSubsequentTest(){ + currentRoll = 7; + Assert.assertTrue(crapsGame.loseOnSubsequent(currentRoll)); + } + + @Test + //tests whether win on subsequent works if they win + public void LoseOnSubsequentTest2(){ + currentRoll = 5; + Assert.assertFalse(crapsGame.loseOnSubsequent(currentRoll)); + } + + @Test + //tests calculateWinnings - whether winning on set the point roll pays out correctly + public void PayOnSetThePointTest1(){ + setThePointRoll = 7; + numRolls = 0; + Assert.assertEquals(100.00, crapsGame.calculateWinnings(wager, setThePointRoll, numRolls), 0.001); + Assert.assertEquals(250.00, player.getBalance(),0.001); + } + + @Test + //tests calculateWinnings - whether winning on 4 or 10 on the first roll pays out correctly + public void Pay4or10firstTest(){ + setThePointRoll = 4; + numRolls = 1; + Assert.assertEquals(300.00, crapsGame.calculateWinnings(wager,setThePointRoll,numRolls), 0.001); + Assert.assertEquals(450.00, player.getBalance(),0.001); + } + + @Test + //tests calculateWinnings - whether winning on 4 or 10 on the second roll pays out correctly + public void Pay4or10secondTest(){ + setThePointRoll = 4; + numRolls = 2; + Assert.assertEquals(250.00, crapsGame.calculateWinnings(wager,setThePointRoll,numRolls), 0.001); + Assert.assertEquals(400.00, player.getBalance(),0.001); + } + + @Test + //tests calculateWinnings - whether winning on 4 or 10 on the third roll pays out correctly + public void Pay4or10thirdTest(){ + setThePointRoll = 4; + numRolls = 3; + Assert.assertEquals(200.00, crapsGame.calculateWinnings(wager,setThePointRoll,numRolls), 0.001); + Assert.assertEquals(350.00, player.getBalance(),0.001); + } + + @Test + //tests calculateWinnings - whether winning on 5 or 9 on the first roll pays out correctly + public void Pay5or9firstTest(){ + setThePointRoll = 5; + numRolls = 1; + Assert.assertEquals(250.00, crapsGame.calculateWinnings(wager,setThePointRoll,numRolls), 0.001); + Assert.assertEquals(400.00, player.getBalance(),0.001); + } + + @Test + //tests calculateWinnings - whether winning on 5 or 9 on the second roll pays out correctly + public void Pay5or9secondTest(){ + setThePointRoll = 5; + numRolls = 2; + Assert.assertEquals(200.00, crapsGame.calculateWinnings(wager,setThePointRoll,numRolls), 0.001); + Assert.assertEquals(350.00, player.getBalance(),0.001); + } + + @Test + //tests calculateWinnings - whether winning on 5 or 9 on the third roll pays out correctly + public void Pay5or9thirdTest(){ + setThePointRoll = 5; + numRolls = 3; + Assert.assertEquals(150.00, crapsGame.calculateWinnings(wager,setThePointRoll,numRolls), 0.001); + Assert.assertEquals(300.00, player.getBalance(),0.001); + } + + @Test + //tests calculateWinnings - whether winning on 6 or 8 on the first roll pays out correctly + public void Pay6or8firstTest(){ + setThePointRoll = 6; + numRolls = 1; + Assert.assertEquals(200.00, crapsGame.calculateWinnings(wager,setThePointRoll,numRolls), 0.001); + Assert.assertEquals(350.00, player.getBalance(),0.001); + } + + @Test + //tests calculateWinnings - whether winning on 6 or 8 on the second roll pays out correctly + public void Pay6or8secondTest(){ + setThePointRoll = 6; + numRolls = 2; + Assert.assertEquals(150.00, crapsGame.calculateWinnings(wager,setThePointRoll,numRolls), 0.001); + Assert.assertEquals(300.00, player.getBalance(),0.001); + } + + @Test + //tests calculateWinnings - whether winning on 6 or 8 on the third roll pays out correctly + public void Pay6or8thirdTest(){ + setThePointRoll = 6; + numRolls = 3; + Assert.assertEquals(100.00, crapsGame.calculateWinnings(wager,setThePointRoll,numRolls), 0.001); + Assert.assertEquals(250.00, player.getBalance(),0.001); + } + + @Test + // tests calculateWinnings - whether losing on set the point roll deducts your balance correctly + public void BalanceDeductsOnSetThePointTest1() { + setThePointRoll = 3; + numRolls = 0; + Assert.assertEquals(0.00, crapsGame.calculateWinnings(wager, setThePointRoll, numRolls), 0.001); + Assert.assertEquals(150.00, player.getBalance(), 0.001); + } + + @Test + public void tossPointRollTest() { + Integer expected = 8; + Integer actual = crapsGame.tossPointRoll(5, 3); + Assert.assertEquals(expected,actual); + } + + @Test + public void winningMessageFirstRollTest() { + String expected = "\n(( You rolled a null on the first roll! ))\n\nCongratulations!!\n\nYou won $0.00!!!\n-------------------------------------------------\n\n"; + String actual = crapsGame.winningMessageFirstRoll(); + Assert.assertEquals(expected, actual); + + } + + @Test + public void losingMessageFirstRoll() { + String expected = "\n(( You rolled a null and have lost on the first roll! ))\n\nThis is unfortunate.....\n\n:(\n-------------------------------------------------\n\n"; + String actual = crapsGame.losingMessageFirstRoll(); + Assert.assertEquals(expected, actual); + } + + @Test + public void losingMessageOutOfRolls() { + + String expected = "(( You are out of rolls. ))\nYou seem to have lost.\nThis is unfortunate.....\n:(\n-------------------------------------------------\n\n"; + String actual = crapsGame.losingMessageOutOfRolls(); + Assert.assertEquals(expected, actual); + } + + @Test + public void tossCurrentRoll() { + Integer expected = 12; + Integer actual = crapsGame.tossPointRoll(7, 5); + Assert.assertEquals(expected,actual); + } + + @Test + public void winOnSubsequentMessage() { + String expected = "Hooray! You rolled a null, and you have won $0.00!! It took you 0 rolls to win."; + String actual = crapsGame.winOnSubsequentMessage(); + Assert.assertEquals(expected, actual); + } + + + @Test + public void loseOnSubsequentMessage() { + String expected = "It appears that the odds were not in your favor today. Better luck next time.....\n-------------------------------------------------\n\n"; + String actual = crapsGame.loseOnSubsequentMessage(); + Assert.assertEquals(expected, actual); + } + + @Test + public void displayCurrentRoll() { + crapsGame.setDie1Current(3); + Integer die1Current= crapsGame.getDie1Current(); + crapsGame.setDie2Current(5); + Integer die2Current= crapsGame.getDie2Current(); + String expected = (DiceGame.diceToASCII(die1Current, die2Current) + String.format(("\n(( You have rolled a 8 for this roll. ))\n"))); + String actual = crapsGame.displayCurrentRoll(8); + Assert.assertEquals(expected, actual); + } + + @Test + public void tossCurrentRoll2() { + Integer expected = 12; + Integer actual = crapsGame.tossCurrentRoll(7, 5); + Assert.assertEquals(expected,actual); + } + + @Test + public void displayPointRoll() { + crapsGame.setDie1Point(4); + Integer die1Point= crapsGame.getDie1Point(); + crapsGame.setDie2Point(6); + Integer die2Point= crapsGame.getDie2Point(); + String expected = "\n-------------------------------------------------" + "SET THE POINT ROLL:\n" + DiceGame.diceToASCII(die1Point, die2Point) + "\n-------------------------------------------------"; + String actual = crapsGame.displayPointRoll(); + Assert.assertEquals(expected, actual); + } + + + //WRITE TEST OF ROUND OF PLAY FOR HOW DIFFERENT TYPES OF LOSSES EFFECT YOUR BALANCE + + /*-------------------I DON'T KNOW HOW TO TEST THESE----------------------- + @Test + // tests whether losing on set the point roll correctly computes balance + public void BalanceAfterLoseOnSetThePointRollTest(){ + setThePointRoll = 3; + numRolls = 0; + crapsGame.roundOfPlay(); + Assert.assertEquals(150.00, player.getBalance(),0.001); + } + + @Test + // tests whether losing on subsequent roll currectly computes balance + public void BalanceAfterLosingOnSubsequentRollTest(){ + + } + + @Test + //tests whether losing due to running out of rolls correctly computes balance + public void BalanceAfterRunningOutOfRollsTest(){ + + } +*/ + +} \ No newline at end of file diff --git a/src/test/java/io/zipcoder/casino/Craps/CrapsPlayerTest.java b/src/test/java/io/zipcoder/casino/Craps/CrapsPlayerTest.java new file mode 100644 index 000000000..b5a23f9c3 --- /dev/null +++ b/src/test/java/io/zipcoder/casino/Craps/CrapsPlayerTest.java @@ -0,0 +1,24 @@ +package io.zipcoder.casino.Craps; + +import io.zipcoder.casino.Player; +import org.junit.Assert; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class CrapsPlayerTest { + + @Test + public void crapsPlayerConstructorTest(){ + Player testPlayer = new Player ("Warren", "G", 40, 1200.0); + CrapsPlayer crapsTest = new CrapsPlayer(testPlayer); + Assert.assertNotNull(crapsTest.getPlayer()); + } + @Test + public void crapsPlayerConstructorTest2(){ + Player testPlayer = new Player ("Warren", "G", 40, 1200.0); + CrapsPlayer crapsTest = new CrapsPlayer(testPlayer); + Assert.assertTrue(crapsTest instanceof CrapsPlayer); + } + +} \ No newline at end of file diff --git a/src/test/java/io/zipcoder/casino/DiceGameTest.java b/src/test/java/io/zipcoder/casino/DiceGameTest.java new file mode 100644 index 000000000..02485aa2c --- /dev/null +++ b/src/test/java/io/zipcoder/casino/DiceGameTest.java @@ -0,0 +1,58 @@ +package io.zipcoder.casino; + +import org.junit.Assert; +import org.junit.Test; + +//import static org.junit.Assert.*; +import io.zipcoder.casino.utilities.Console; + +public class DiceGameTest { + + private Console console = new Console(System.in, System.out); + + @Test + public void testRoll2() { + for (int i = 0; i < 1000; i++) { + int expected = DiceGame.roll(2, 10); + Assert.assertTrue((expected >= 2 && expected <= 20)); + } + } + + @Test + public void testRoll3() { + for (int i = 0; i < 1000; i++) { + int expected = DiceGame.roll(3, 8); + Assert.assertTrue((expected >= 3 && expected <= 24)); + } + } + + @Test + public void testRoll() { + for (int i = 0; i < 1000; i++) { + int expected = DiceGame.roll(1, 6); + Assert.assertTrue((expected >= 1 && expected <= 6)); + } + } + + @Test + public void testRoll1() { + for (int i = 0; i < 1000; i++) { + int expected = DiceGame.roll(3); + Assert.assertTrue((expected >= 3 && expected <= 18)); + } + } + + @Test + public void testRoll4() { + for (int i = 0; i < 1000; i++) { + int expected = DiceGame.roll(); + Assert.assertTrue((expected >= 1 && expected <= 6)); + } + } + + @Test + public void ASCIITest() { + console.println(DiceGame.diceToASCII(1,2,3,4,5,6)); + } +} + diff --git a/src/test/java/io/zipcoder/casino/GoFish/GoFishGameTest.java b/src/test/java/io/zipcoder/casino/GoFish/GoFishGameTest.java new file mode 100644 index 000000000..0497b1a82 --- /dev/null +++ b/src/test/java/io/zipcoder/casino/GoFish/GoFishGameTest.java @@ -0,0 +1,269 @@ +package io.zipcoder.casino.GoFish; + + +import io.zipcoder.casino.Card; +import io.zipcoder.casino.CardSet; +import io.zipcoder.casino.Menus.GoFishMenu; +import io.zipcoder.casino.Player; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.util.ArrayList; + +public class GoFishGameTest { + private GoFishMenu goFishMenu; + private GoFishGame goFishGame; + private Player player; + private GoFishPlayer goFishPlayer; + private GoFishNPC opponent; + private GoFishNPC goFishNPC; + private CardSet playersCards; + private CardSet opponentCards; + private CardSet shoe; + private CardSet playerSuites; + private CardSet opponentSuites; + + + @Before + public void before() { + player = new Player("Bamboo", "Rod", 25, 15); + goFishGame = new GoFishGame(player); + goFishMenu = new GoFishMenu(); + goFishPlayer = goFishGame.getPlayer(); + opponent = goFishGame.getOpponent(); + shoe = new CardSet(1); + playersCards = goFishGame.getPlayersCards(); + opponentCards = goFishGame.getOpponentsCards(); + playerSuites = goFishGame.getPlayerSuites(); + opponentSuites = goFishGame.getOpponentSuites(); + } + + @Test + public void getNameTest() { + Assert.assertEquals("Go Fish", goFishGame.getName()); + } + + @Test + public void startGameTest() { + + } + + @Test + public void initialDealPlayer() { + int actual = playersCards.size(); + int expected = 0; + Assert.assertEquals(actual, expected); + goFishGame.initialDeal(); + actual = playersCards.size(); + expected = 7; + Assert.assertEquals(actual, expected); + } + + @Test + public void initialDealOpponent() { + int actual = opponentCards.size(); + int expected = 0; + Assert.assertEquals(actual, expected); + goFishGame.initialDeal(); + actual = opponentCards.size(); + expected = 7; + Assert.assertEquals(actual, expected); + } + + @Test + public void integrateStolenCardsTest() { + ArrayList stolenCards = new ArrayList(); + goFishGame.initialDeal(); + Card card1 = new Card("J", "H"); + Card card2 = new Card("J", "D"); + stolenCards.add(card1); + stolenCards.add(card2); + int actual = playersCards.size(); + int expected = 7; + Assert.assertEquals(expected, actual); + goFishGame.integrateStolenCards(stolenCards, goFishGame.getPlayersCards()); + actual = playersCards.size(); + expected = 9; + Assert.assertEquals(expected, actual); + + } + + @Test + public void drawCardTest() { + goFishGame.initialDeal(); + int actual = playersCards.size(); + int expected = 7; + Assert.assertEquals(expected, actual); + goFishGame.drawCard(playersCards); + actual = playersCards.size(); + expected = 8; + Assert.assertEquals(expected, actual); + } + + @Test + public void emptyHandDrawCardTest() { + + int actual = playersCards.size(); + int expected = 0; + Assert.assertEquals(expected, actual); + goFishGame.emptyHandDraw(playersCards); + actual = playersCards.size(); + expected = 1; + Assert.assertEquals(expected, actual); + } + + @Test + public void winCheckTest1() { + for (int i = 0; i < 6; i++ ) { + playerSuites.addCard(new Card("A", "H")); + } + for (int i = 0; i < 4; i++ ) { + opponentSuites.addCard(new Card("A", "H")); + } + GoFishPlayer expected = null; + GoFishPlayer actual = goFishGame.checkForWin(goFishPlayer, goFishNPC, playerSuites, opponentSuites); + Assert.assertEquals(expected, actual); + } + + @Test + public void winCheckTest2() { + for (int i = 0; i < 6; i++ ) { + playerSuites.addCard(new Card("A", "H")); + } + for (int i = 0; i < 8; i++ ) { + opponentSuites.addCard(new Card("A", "H")); + } + GoFishPlayer expected = opponent; + GoFishPlayer actual = goFishGame.checkForWin(goFishPlayer, opponent, playerSuites, opponentSuites); + Assert.assertEquals(expected, actual); + } + + @Test + public void winCheckTest3() { + for (int i = 0; i < 0; i++ ) { + playerSuites.addCard(new Card("A", "H")); + } + for (int i = 0; i < 4; i++ ) { + opponentSuites.addCard(new Card("A", "H")); + } + GoFishPlayer expected = null; + GoFishPlayer actual = goFishGame.checkForWin(goFishPlayer, goFishNPC, playerSuites, opponentSuites); + Assert.assertEquals(expected, actual); + } + + @Test + public void winCheckTest4() { + for (int i = 0; i < 8; i++) { + playerSuites.addCard(new Card("A", "H")); + } + for (int i = 0; i < 4; i++) { + opponentSuites.addCard(new Card("A", "H")); + } + GoFishPlayer expected = goFishPlayer; + GoFishPlayer actual = goFishGame.checkForWin(goFishPlayer, goFishNPC, playerSuites, opponentSuites); + Assert.assertEquals(expected, actual); + } + + +// @Test +// public void npcPickACardTest(){ +// playersCards = new CardSet(0); +// opponentCards = new CardSet(0); +// opponentCards.addCard(new Card("A","S")); +// opponentCards.addCard(new Card("A","H")); +// opponentCards.addCard(new Card("A","D")); +// opponentCards.addCard(new Card("K","C")); +// opponentCards.addCard(new Card("2","H")); +// opponentCards.addCard(new Card("K","D")); +// opponentCards.addCard(new Card("5","C")); +// +// ArrayList testHand = opponentCards.getCards(); +// String testCard = goFishGame.getOpponent().chooseCard(); +// for (int i = 0; i < opponentCards.size(); i++) { +// if (opponentCards.getCards(). == testCard) { +// +// } +// } +// +// } + + @Test + public void scanForSuitesTest(){ + playersCards.addCard(new Card("A","C")); + playersCards.addCard(new Card("A","H")); + playersCards.addCard(new Card("A","D")); + playersCards.addCard(new Card("A","C")); + playersCards.addCard(new Card("2","H")); + playersCards.addCard(new Card("K","D")); + playersCards.addCard(new Card("5","H")); + + int testHand = playersCards.size(); + goFishGame.scanForSuites(playersCards, playerSuites, "A"); + int postScanHand = playersCards.size(); + System.out.println(playersCards.getCards().get(0).toString()); + Assert.assertEquals(testHand-4,postScanHand); + + } + + @Test + public void showPlayerSuitesTest() { + playerSuites.addCard(new Card("A", "H")); + CardSet set = new CardSet(0); + set.addCard(new Card("A", "H")); + + String expected = "************************* PLAYER'S SUITES *************************\n" + set.toASCIISuite() + "\n"; + String actual = goFishGame.displayPlayerSuites(); + + Assert.assertEquals(expected, actual); + } + + @Test + public void showOpponentSuitesTest() { + opponentSuites.addCard(new Card("J", "D")); + CardSet set = new CardSet(0); + set.addCard(new Card("J", "D")); + + String expected = "************************ OPPONENT'S SUITES ************************\n" + set.toASCIISuite() + "\n"; + String actual = goFishGame.displayOpponentSuites(); + + Assert.assertEquals(expected, actual); + } + + @Test + public void showPlayerHandTest() { + playersCards.addCard(new Card("A", "H")); + playersCards.addCard(new Card("9", "S")); + playersCards.addCard(new Card("2", "C")); + CardSet set = new CardSet(0); + set.addCard(new Card("A", "H")); + set.addCard(new Card("9", "S")); + set.addCard(new Card("2", "C")); + + String expected = "************************** PLAYER'S HAND **************************\n" + set.toASCII() + "\n"; + String actual = goFishGame.displayPlayerHands(); + + Assert.assertEquals(expected, actual); + } + + @Test + public void showOpponentHandTest() { + opponentCards.addCard(new Card("A", "H")); + opponentCards.addCard(new Card("9", "S")); + opponentCards.addCard(new Card("2", "C")); + CardSet set = new CardSet(0); + set.addCard(new Card("A", "H")); + set.addCard(new Card("9", "S")); + set.addCard(new Card("2", "C")); + + String expected = "************************* OPPONENT'S HAND *************************\n" + set.toASCIIBlank() + "\n"; + String actual = goFishGame.displayOpponentHands(); + + Assert.assertEquals(expected, actual); + } + + @Test + public void titleTest() { + goFishGame.goTitleScreen(); + } +} diff --git a/src/test/java/io/zipcoder/casino/GoFish/GoFishNPCTest.java b/src/test/java/io/zipcoder/casino/GoFish/GoFishNPCTest.java new file mode 100644 index 000000000..56990ec61 --- /dev/null +++ b/src/test/java/io/zipcoder/casino/GoFish/GoFishNPCTest.java @@ -0,0 +1,44 @@ +package io.zipcoder.casino.GoFish; + +import io.zipcoder.casino.Card; +import io.zipcoder.casino.CardSet; +import io.zipcoder.casino.Menus.GoFishMenu; +import io.zipcoder.casino.Player; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.util.ArrayList; + +import static org.junit.Assert.*; + +public class GoFishNPCTest { + + private Player player; + private GoFishPlayer goFishPlayer; + private GoFishGame goFishGame; + private GoFishNPC opponent; + + @Before + public void setUp() { + player = new Player("Bamboo", "Rod", 25, 15); + goFishGame = new GoFishGame(player); + goFishPlayer = goFishGame.getPlayer(); + opponent = goFishGame.getOpponent(); + } + + @Test + public void chooseCardTest() { + goFishGame.initialDeal(); + CardSet hand = goFishGame.getOpponentsCards(); + ArrayList ranks = new ArrayList(); + for (Card card : hand.getCards()) { + ranks.add(card.getRank()); + } + + for (int i = 0; i < 20; i++ ){ + String chosenRank = opponent.chooseCard(hand); + Assert.assertTrue(ranks.contains(chosenRank)); + } + } +} \ No newline at end of file diff --git a/src/test/java/io/zipcoder/casino/GoFish/GoFishPlayerTest.java b/src/test/java/io/zipcoder/casino/GoFish/GoFishPlayerTest.java new file mode 100644 index 000000000..880c41032 --- /dev/null +++ b/src/test/java/io/zipcoder/casino/GoFish/GoFishPlayerTest.java @@ -0,0 +1,30 @@ +package io.zipcoder.casino.GoFish; + +import io.zipcoder.casino.Player; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class GoFishPlayerTest { + + private Player player; + private GoFishPlayer goFishPlayer; + + @Before + public void before() { + player = new Player("Scrubby", "Bubbles", 7, 6); + goFishPlayer = new GoFishPlayer(player); + } + + @Test + public void getPlayerTest() { + Assert.assertEquals(player, goFishPlayer.getPlayer()); + Assert.assertEquals(6, goFishPlayer.getPlayer().getBalance(),.01); + + + } + @Test + public void getPlayerNameTest(){ + + } +} diff --git a/src/test/java/io/zipcoder/casino/GoFish/GoFishRoundTest.java b/src/test/java/io/zipcoder/casino/GoFish/GoFishRoundTest.java new file mode 100644 index 000000000..3967970cb --- /dev/null +++ b/src/test/java/io/zipcoder/casino/GoFish/GoFishRoundTest.java @@ -0,0 +1,4 @@ +package io.zipcoder.casino.GoFish; + +public class GoFishRoundTest { +} diff --git a/src/test/java/io/zipcoder/casino/Menus/BlackjackMenuTest.java b/src/test/java/io/zipcoder/casino/Menus/BlackjackMenuTest.java new file mode 100644 index 000000000..561591d53 --- /dev/null +++ b/src/test/java/io/zipcoder/casino/Menus/BlackjackMenuTest.java @@ -0,0 +1,55 @@ +package io.zipcoder.casino.Menus; + +import io.zipcoder.casino.Blackjack.BlackjackGame; +import io.zipcoder.casino.Player; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class BlackjackMenuTest { + + private BlackjackMenu blackjackMenu; + private BlackjackGame blackjackGame; + private Player player; + + @Before + public void setUp() throws Exception { + player = new Player("William", "Adama", 45, 300.00); + blackjackGame = new BlackjackGame(0.0, 0.0, player); + blackjackMenu = new BlackjackMenu(blackjackGame); + } + + @Test + public void getNameTest() { + Assert.assertEquals("Blackjack Menu",blackjackMenu.getName()); + } + + @Test + public void handleChoiceTest1() { + Assert.assertEquals(0.00,blackjackGame.getMinBet(), .01); + Assert.assertEquals(0.00,blackjackGame.getMaxBet(), .01); + } + + @Test + public void handleChoiceTest2() { + blackjackMenu.handleChoice(1); + Assert.assertEquals(5.00,blackjackGame.getMinBet(), .01); + Assert.assertEquals(25.00,blackjackGame.getMaxBet(), .01); + } + + @Test + public void handleChoiceTest3() { + blackjackMenu.handleChoice(2); + Assert.assertEquals(20.00,blackjackGame.getMinBet(), .01); + Assert.assertEquals(100.00,blackjackGame.getMaxBet(), .01); + } + + @Test + public void handleChoiceTest4() { + blackjackMenu.handleChoice(3); + Assert.assertEquals(50.00,blackjackGame.getMinBet(), .01); + Assert.assertEquals(250.00,blackjackGame.getMaxBet(), .01); + } +} \ No newline at end of file diff --git a/src/test/java/io/zipcoder/casino/Menus/CasinoTest.java b/src/test/java/io/zipcoder/casino/Menus/CasinoTest.java new file mode 100644 index 000000000..680f70645 --- /dev/null +++ b/src/test/java/io/zipcoder/casino/Menus/CasinoTest.java @@ -0,0 +1,5 @@ +package io.zipcoder.casino.Menus; + + +public class CasinoTest { +} diff --git a/src/test/java/io/zipcoder/casino/Menus/GameMenuTest.java b/src/test/java/io/zipcoder/casino/Menus/GameMenuTest.java new file mode 100644 index 000000000..db6369c10 --- /dev/null +++ b/src/test/java/io/zipcoder/casino/Menus/GameMenuTest.java @@ -0,0 +1,66 @@ +package io.zipcoder.casino.Menus; + +import io.zipcoder.casino.GameObject; +import io.zipcoder.casino.Player; +import io.zipcoder.casino.Services.GameRepo; +import org.junit.Assert; +import org.junit.Test; + +import java.util.HashMap; + +import static org.junit.Assert.*; + +public class GameMenuTest { + + + @Test + public void mapSizeTest() { + Player player = new Player("June", "Cleaver", 35, 0.00); + + GameMenu gameMenu = new GameMenu(player); + GameRepo gameRepo = gameMenu.getGameRepo(); + HashMap map = gameMenu.getGameMap(); + + Assert.assertEquals(GameRepo.NUM_ADULT_GAMES + GameRepo.NUM_KID_GAMES + 1, map.size()); + + } + + @Test + public void mapSizeTest2() { + Player player = new Player("Beaver", "Cleaver", 13, 0.00); + + GameMenu gameMenu = new GameMenu(player); + GameRepo gameRepo = gameMenu.getGameRepo(); + HashMap map = gameMenu.getGameMap(); + + Assert.assertEquals(GameRepo.NUM_KID_GAMES + 1, map.size()); + } + + @Test + public void printTestAdult() { + Player player = new Player("June", "Cleaver", 35, 0.00); + + GameMenu gameMenu = new GameMenu(player); + GameRepo gameRepo = gameMenu.getGameRepo(); +// gameMenu.displayMenu(); + } + + @Test + public void printTestKid() { + Player player = new Player("Beaver", "Cleaver", 13, 0.00); + + GameMenu gameMenu = new GameMenu(player); + GameRepo gameRepo = gameMenu.getGameRepo(); +// gameMenu.displayMenu(); + } + + @Test + public void printTestAdulttemp() { + Player player = new Player("June", "Cleaver", 35, 0.00); + + GameMenu gameMenu = new GameMenu(player); + GameRepo gameRepo = gameMenu.getGameRepo(); +// gameMenu.displayMenu(); +// gameMenu.handleChoice(2); + } +} \ No newline at end of file diff --git a/src/test/java/io/zipcoder/casino/Menus/MainMenuTest.java b/src/test/java/io/zipcoder/casino/Menus/MainMenuTest.java new file mode 100644 index 000000000..bf96d9d5f --- /dev/null +++ b/src/test/java/io/zipcoder/casino/Menus/MainMenuTest.java @@ -0,0 +1,11 @@ +package io.zipcoder.casino.Menus; + +import io.zipcoder.casino.Player; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class MainMenuTest { + + +} \ No newline at end of file diff --git a/src/test/java/io/zipcoder/casino/RR/RRGameTest.java b/src/test/java/io/zipcoder/casino/RR/RRGameTest.java new file mode 100644 index 000000000..cd5a540d0 --- /dev/null +++ b/src/test/java/io/zipcoder/casino/RR/RRGameTest.java @@ -0,0 +1,175 @@ +package io.zipcoder.casino.RR; + + +import io.zipcoder.casino.DiceGame; +import io.zipcoder.casino.Player; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class RRGameTest{ + +//import static org.junit.Assert.*; + + + private RRGame testGame; + private Player dave; + private Player testPlayer; + private Integer computersRoll; + private Integer userDieNum; + private RRGame testGame2; + + @Before + public void setUp () { + dave = new Player("David", "Trombello", 37, 500); + testGame = new RRGame(dave); + testPlayer = new Player("Grace", "Bunde", 23, 500.00); + testGame2 = new RRGame(testPlayer); + } + + @Test + public void computerRollTest() { + for (int i = 0; i < 1000; i++) { + Integer expected = testGame.computerRoll(); + Assert.assertTrue((expected >= 1 && expected <= 6)); + + } + } + + + @Test + public void getFirstName() { + // Given + + String expected = "Grace"; + + // Then + String actual = testPlayer.getFirstName(); + Assert.assertEquals(expected, actual); + } + + @Test + public void getLastName() { + // Given + + String expected = "Trombello"; + + // Then + String actual = dave.getLastName(); + Assert.assertEquals(expected, actual); + } + + @Test + public void getAge() { + // Given + + Integer expected = 23; + + // Then + Integer actual = testPlayer.getAge(); + Assert.assertEquals(expected, actual); + } + @Test + public void getBalance() { + // Given + dave.setBalance(500.00); + Double expected = 500.00; + + // Then + Double actual = dave.getBalance(); + Assert.assertEquals(expected, actual); + } + + @Test + public void houseDisplayRollTest () { + testGame.setComputersRoll(5); + Integer computersRoll = testGame.getComputersRoll(); + String expected = "------------------------------------------------------\n\n** The House rolled 5 **\n" + DiceGame.diceToASCII(computersRoll); + String actual = testGame.houseRollDisplay(computersRoll); + Assert.assertEquals(expected , actual); + } + + @Test + public void userRollDisplay() { + testGame.setUserDieNum(6); + Integer userDieNum = testGame.getUserDieNum(); + String expected = "------------------------------------------------------\n** You rolled 6 **\n\n" + DiceGame.diceToASCII(userDieNum); + String actual = testGame.userRollDisplay(userDieNum); + Assert.assertEquals(expected, actual); + } + + + @Test + public void displayUserBalance() { + dave.setBalance(535.00); + String expected = "Your Current Balance Is 535.00"; + String actual = testGame.displayUserBalance(); + Assert.assertEquals(expected, actual); + } + + @Test + public void displayWinnerBalance() { + testPlayer.setBalance(825); + String expected = "\n\nYou Won!!! Your Balance Is Now $825.00\n"; + String actual = testGame2.displayWinnerBalance(); + Assert.assertEquals(expected, actual); + } + + + @Test + public void getName() { + String expected = "Russian Dice Roulette"; + String actual = testGame.getName(); + Assert.assertEquals(expected, actual); + } + + @Test + public void printElFin() { + String expected = " ,ggggggg, ,gggggggggggggg \n" + + " ,dP\"\"\"\"\"\"Y8b ,dPYb, dP\"\"\"\"\"\"88\"\"\"\"\"\" \n" + + " d8' a Y8 IP'`Yb Yb,_ 88 \n" + + " 88 \"Y8P' I8 8I `\"\" 88 gg \n" + + " `8baaaa I8 8' ggg88gggg \"\" \n" + + ",d8P\"\"\"\" I8 dP 88 8 gg ,ggg,,ggg, \n" + + "d8\" I8dP 88 88 ,8\" \"8P\" \"8, \n" + + "Y8, I8P gg, 88 88 I8 8I 8I \n" + + "`Yba,,_____, ,d8b,_ \"Yb,,8P _,88,_,dP 8I Yb,\n" + + " `\"Y8888888 8P'\"Y88 \"Y8P' 8P\"\"Y88P' 8I `Y8\n\n\n\n"; + String actual = testGame.printElFin(); + Assert.assertEquals(expected, actual); + } + + @Test + public void printPistol() { + String expected = " \n\n\n" + + " ) /=>\n" + + " ( +____________________/\\/\\___ / /|\n" + + " .''._____________'._____ / /|/\\\n" + + " : () : :\\ ----\\| \\ )\n" + + " '..'______________.'0|----| \\\n" + + " 0_0/____/ \\\n" + + " |---- /----\\\n" + + " || -\\\\ --| \\\n" + + " || || ||\\ \\\n" + + " \\\\____// '| \\\n" + + " Bang! .'/ |\n" + + " .:/ |\n" + + " :/_________|"; + String actual = testGame.printPistol(); + Assert.assertEquals(expected, actual); + } + + @Test + public void printLosingMessage() { + String expected = "\nYou Lost!!!"; + String actual = testGame.printLosingMessage(); + Assert.assertEquals(expected, actual); + } + + @Test + public void printDealersLosingMessage() { + String expected = "[DEALER]: Don't you know how Russian Roulette works?\n\n"; + String actual = testGame.printDealersLosingMessage(); + Assert.assertEquals(expected,actual); + } +} diff --git a/src/test/java/io/zipcoder/casino/Services/GameRepoTest.java b/src/test/java/io/zipcoder/casino/Services/GameRepoTest.java new file mode 100644 index 000000000..25ef39581 --- /dev/null +++ b/src/test/java/io/zipcoder/casino/Services/GameRepoTest.java @@ -0,0 +1,35 @@ +package io.zipcoder.casino.Services; + +import io.zipcoder.casino.GameObject; +import io.zipcoder.casino.Player; +import org.junit.Assert; +import org.junit.Test; + +import java.util.HashMap; + +import static org.junit.Assert.*; + +public class GameRepoTest { + + @Test + public void constructorTestAdult() { + Player player = new Player("June", "Cleaver", 35, 0.00); + GameRepo gameRepo = new GameRepo(player); + + HashMap map = gameRepo.getGamesMap(); + + Assert.assertEquals(GameRepo.NUM_ADULT_GAMES + GameRepo.NUM_KID_GAMES + 1, map.size()); + + } + + @Test + public void constructorTestUnder21() { + Player player = new Player("Beaver", "Cleaver", 13, 0.00); + GameRepo gameRepo = new GameRepo(player); + + HashMap map = gameRepo.getGamesMap(); + + Assert.assertEquals(GameRepo.NUM_KID_GAMES + 1, map.size()); + } + +} \ No newline at end of file diff --git a/src/test/java/io/zipcoder/casino/Services/GameServicesTest.java b/src/test/java/io/zipcoder/casino/Services/GameServicesTest.java new file mode 100644 index 000000000..3fe393f6a --- /dev/null +++ b/src/test/java/io/zipcoder/casino/Services/GameServicesTest.java @@ -0,0 +1,70 @@ +package io.zipcoder.casino.Services; + +import io.zipcoder.casino.Blackjack.BlackjackGame; +import io.zipcoder.casino.Player; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class GameServicesTest { + + private Player player; + private BlackjackGame blackjackGame; + private GameServices gameServices; + @Before + public void setUp() throws Exception { + player = new Player ("Jeff", "Steinbeck", 35, 200.00); + gameServices = new GameServices(); + } + + @Test + public void getWagerTest() { + Assert.assertFalse(gameServices.wager(300.00, player)); + } + + @Test + public void getWagerTest2() { + Assert.assertTrue(gameServices.wager(100.00, player)); + Assert.assertEquals(100.00, player.getBalance(), .01); + } + + @Test + public void getWagerTest3() { + Assert.assertTrue(gameServices.wager(199.00, player)); + Assert.assertEquals(1.00, player.getBalance(), .01); + } + + @Test + public void withdrawTest() { + Assert.assertEquals(200.00, gameServices.withdraw(player), .01); + Assert.assertEquals(0.00, player.getBalance(), .01); + } + + @Test + public void withdrawTest2() { + player.setBalance(0.0); + Assert.assertEquals(0.00, gameServices.withdraw(player), .01); + Assert.assertEquals(0.00, player.getBalance(), .01); + } + + @Test + public void depositTest() { + player.setBalance(0.0); + Assert.assertEquals(0.00, gameServices.withdraw(player), .01); + gameServices.deposit(100.0, player); + Assert.assertEquals(100.00, player.getBalance(), .01); + + } + + @Test + public void payOut() { + gameServices.payOut(100.00, player); + Assert.assertEquals(300.00, player.getBalance(), .01); + } + + @Test + public void payOut2() { + gameServices.payOut(0.00, player); + Assert.assertEquals(200.00, player.getBalance(), .01); + } +} \ No newline at end of file