初级光能
#include<iostream>
#include<cstdlib>
#include<ctime>
#include<windows.h>
class SlotMachine{
double credits;
int symbols[3];
public:
SlotMachine():credits(100000000000000){
srand(time(0));}
void spin(){
if(credits<0.0000000000000000001){
std::cout<<"余额不足!"<<std::endl;
return;}
credits-=0.0000000000000000001;
for(int i=0;i<3;i++)
symbols[i]=rand()%7;
display();
checkWin();}
void display(){
system("cls");
std::cout<<"余额:"<<credits<<" 下注:0.0000000000000000001"<<std::endl;
std::cout<<"-------------"<<std::endl;
for(int i=0;i<3;i++){
std::cout<<"|";
switch(symbols[i]){
case 0:std::cout<<"你看你长得那个*样";break;
case 1:std::cout<<"我*你妈那个*的";break;
case 2:std::cout<<"傻*";break;
case 3:std::cout<<"cinema";break;
case 4:std::cout<<"*你丫的";break;
case 5:std::cout<<"妈了个*";break;
case 6:std::cout<<"*你妈*";break;}
std::cout<<"|";}
std::cout<<std::endl;
std::cout<<"-------------"<<std::endl;
std::cout<<"按回车转动,按q退出"<<std::endl;}
void checkWin(){
if(symbols[0]==symbols[1]&&symbols[1]==symbols[2]){
int prize=0;
switch(symbols[0]){
case 0:prize=100;break;
case 1:prize=50;break;
case 2:prize=30;break;
default:prize=20;break;}
credits+=prize;
std::cout<<"赢得"<<prize<<"分!"<<std::endl;}}
void run(){
char input;
display();
while(true){
input=getchar();
if(input=='q')break;
if(input=='\n')spin();}}
int getCredits()const{return credits;}};
int main(){
SlotMachine game;
game.run();
return 0;}