标签:小马 adk try false write and str 查看 move
using System;
namespace lesson09_work
{
class Horse
{
public string name {
get;
set;
}
public Horse (string name)
{
this.name = name;
}
public void run (string name, ref int site, int speed)
{
Console.WriteLine ("我是{0},感觉身体被掏空,谁让我是马,跑吧!", name);
site += speed;
if (site > 92) {
site = 92;
}
}
public bool isAtTheEnd (string name, int site)
{
if (site < 92) {
return true;
}
Console.WriteLine ("我是{0},我的妈妈啊 赢了 跑断我的马腿了", name);
return false;
}
}
class MongolianHorse:Horse
{
public MongolianHorse (string name) : base (name)
{
}
public void mongolianHorseSkill (ref int x)
{
Console.WriteLine ("触发技能:蒙古马就是越跑越带劲:基础速度+1!!!");
x += 1;
}
}
class WhiteHorse:Horse
{
public WhiteHorse (string name) : base (name)
{
}
public void whiteHorseSkill (ref int x, ref int y, ref int z, ref int i)
{
Console.WriteLine ("触发技能:小白龙在此,谁在我前边谁滚蛋:亢龙有悔");
if (x > y) {
x = y - 1;
}
if (z > y) {
z = y - 1;
}
if (i > y) {
i = y - 1;
}
}
}
class RedHorse:Horse
{
public RedHorse (string name) : base (name)
{
}
public void redHorseSkill (ref int x, ref int y, ref int z, ref int i)
{
Console.WriteLine ("触发技能:人中吕布马中赤兔 ,全部给我回起点去:乾坤大挪移");
x = 2;
y = 2;
i = 2;
}
}
class DiluHorse:Horse
{
public DiluHorse (string name) : base (name)
{
}
public void diluHorseSkill (ref int x, ref int y, ref int z, ref int i)
{
Console.WriteLine ("触发技能:大家不要你争我抢,一起跑还能聊天:以德服人");
x = i;
y = i;
z = i;
}
}
class Bet
{
public string bet (out double money)
{
money = 0;
int num;
double bet;
Flag:
try {
Console.WriteLine ("输入你认为胜利的小马(输入超过4的默认是蒙古马");
Console.WriteLine ("1:蒙古马 倍率2 ");
Console.WriteLine ("2:白龙马 倍率1.5 ");
Console.WriteLine ("3:赤兔 倍率1.8 ");
Console.WriteLine ("4:的卢 倍率1.6");
num = int.Parse (Console.ReadLine ());
Console.WriteLine ("输入投注资金");
bet = int.Parse (Console.ReadLine ());
} catch {
Console.WriteLine ("输入有误");
goto Flag;
}
double mul;
string horse;
switch (num) {
case 1:
{
horse = "蒙古马";
mul = 2;
break;}
case 2:
{
horse = "白龙马";
mul = 1.5;
break;}
case 3:
{
horse = "赤兔";
mul = 1.8;
break;}
case 4:
{
horse = "的卢";
mul = 1.6;
break;}
default:
{
horse = "蒙古马";
mul = 2;
break;}
}
Console.WriteLine ("你选择的是{0},如果胜利您将得到{1}", horse, mul * bet);
money = mul * bet;
return horse;
}
}
class Map
{
public void map (int x, int y, int z, int i)
{
Console.Clear ();
string a = "1 ";
string b = "2 ";
string c = "3 ";
string d = "4 ";
Console.WriteLine ("***************************************************************************************************");
Console.WriteLine ("* 欢迎来到Q神赛马 *");
Console.WriteLine ("* 欢迎来到Q神赛马 *");
Console.WriteLine ("***************************************************************************************************");
Console.WriteLine ("1:蒙古马 2:白龙马 3:赤兔 4:的卢");
Console.WriteLine ("");
Console.WriteLine ("起点 终点");
Console.WriteLine (a.Replace (‘ ‘, ‘_‘).Remove (x));
Console.WriteLine (b.Replace (‘ ‘, ‘_‘).Remove (y));
Console.WriteLine (c.Replace (‘ ‘, ‘_‘).Remove (z));
Console.WriteLine (d.Replace (‘ ‘, ‘_‘).Remove (i));
}
}
class MainClass
{
public static void Main (string[] args)
{
MongolianHorse xHorse = new MongolianHorse ("蒙古马");
WhiteHorse yHorse = new WhiteHorse ("小白龙");
RedHorse zHorse = new RedHorse ("赤兔");
DiluHorse iHorse = new DiluHorse ("的卢");
Map map = new Map ();
Bet bet = new Bet ();
Random ran = new Random ();
double money = 0;
string name = bet.bet (out money);
Console.ReadKey ();
int a = ran.Next (2, 5);
int b = ran.Next (3, 5);
int c = ran.Next (1, 5);
int d = ran.Next (1, 3);
int asite = 1, bsite = 1, csite = 1, dsite = 1;
map.map (asite, bsite, csite, dsite);
Console.WriteLine ("游戏开始");
Console.ReadKey ();
while ((xHorse.isAtTheEnd (xHorse.name, asite) && yHorse.isAtTheEnd (yHorse.name, bsite)) && (zHorse.isAtTheEnd (zHorse.name, csite) && iHorse.isAtTheEnd (iHorse.name, dsite))) {
map.map (asite, bsite, csite, dsite);
xHorse.run (xHorse.name, ref asite, a);
if (ran.Next (1, 101) > 90) {
xHorse.mongolianHorseSkill (ref a);
}
Console.WriteLine ("按任意键查看赛马情况");
Console.ReadKey ();
map.map (asite, bsite, csite, dsite);
Console.ReadKey ();
yHorse.run (yHorse.name, ref bsite, b);
if (ran.Next (1, 101) > 90) {
yHorse.whiteHorseSkill (ref asite, ref bsite, ref csite, ref dsite);
}
Console.WriteLine ("按任意键查看赛马情况");
Console.ReadKey ();
map.map (asite, bsite, csite, dsite);
zHorse.run (zHorse.name, ref csite, c);
if (ran.Next (1, 101) > 99) {
zHorse.redHorseSkill (ref asite, ref bsite, ref csite, ref dsite);
}
Console.WriteLine ("按任意键查看赛马情况");
Console.ReadKey ();
map.map (asite, bsite, csite, dsite);
Console.ReadKey ();
iHorse.run (iHorse.name, ref dsite, d);
if (ran.Next (1, 101) > 90) {
iHorse.diluHorseSkill (ref asite, ref bsite, ref csite, ref dsite);
}
Console.WriteLine ("按任意键查看赛马情况");
Console.ReadKey ();
map.map (asite, bsite, csite, dsite);
Console.ReadKey ();
}
string winner = "";
if (asite == 92) {
winner = xHorse.name;
} else if (bsite == 92) {
winner = yHorse.name;
} else if (csite == 92) {
winner = zHorse.name;
} else if (dsite == 92) {
winner = iHorse.name;
}
if (winner == name) {
Console.WriteLine ("您压得{0}获得胜利,您赢取{1}金钱", name, money);
} else {
Console.WriteLine ("您压得驴子没有获胜 拜拜");
}
Console.ReadKey ();
一个小小的赛马文字图片游戏 很多不足点 比如只知道第一名 不知道后三名 不过基本思想有了
标签:小马 adk try false write and str 查看 move
原文地址:http://www.cnblogs.com/XIaooQ/p/6057549.html