資源簡介
常玩的過河益智小游戲,通過控制臺接收用戶輸入實現,邏輯不是很復雜,希望大家來搞
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Linq;
using?System.Text;
using?System.Threading.Tasks;
namespace?過河
{
????class?Program
????{
????????static?List?left_people?=?new?List();
????????static?List?right_people?=?new?List();
????????static?List?boat_people?=?new?List();
????????static?List?all_people?=?new?List();
????????static?string[]?boatOk?=?new?string[]?{?“警察“?“爸爸“?“媽媽“?};
????????static?void?Main(string[]?args)
????????{
????????????bool?isLeft?=?true;
????????????bool?isRepit?=?true;
????????????string?input?=?““;
????????????InitPeople();
?????????????while?(true)
????????????????{
????????????????????do
????????????????????{
????????????????????????
????????????????????????if?(isRepit)
????????????????????????{
????????????????????????????Show();
????????????????????????????while?(true)
????????????????????????????{
????????????????????????????????OnBoat(isLeft);
????????????????????????????????if?(Check()?==?false)
????????????????????????????????{
????????????????????????????????????OutBoat();
????????????????????????????????}
????????????????????????????????else
????????????????????????????????{
????????????????????????????????????break;
????????????????????????????????}
????????????????????????????}
????????????????????????????if?(isLeft)
????????????????????????????{
????????????????????????????????Reduce(left_people);
????????????????????????????????Add(right_people);
????????????????????????????????if?(CheckSuccess(left_people)?&&?CheckSuccess(right_people))
????????????????????????????????{
????????????????????????????????????OutBoat();
????????????????????????????????????isLeft?=?false;
????????????????????????????????}
????????????????????????????????else
????????????????????????????????{
????????????????????????????????????Console.WriteLine(“游戲失敗是否重來,Y:是,N:否“);
????????????????????????????????????input?=?Console.ReadLine();
????????????????????????????????????break;
????????????????????????????????}
????????????????????????????}
????????????????????????????else
????????????????????????????{
????????????????????????????????Reduce(right_people);
????????????????????????????????Add(left_people);
????????????????????????????????if?(CheckSuccess(left_people)?&&?CheckSuccess(right_people))
????????????????????????????????{
????????????????????????????????????OutBoat();
????????????????????????????????????isLeft?=?true;
????????????????????????????????}
????????????????????????????????else
????????????????????????????????{
????????????????????????????????????Console.WriteLine(“游戲失敗是否重來,Y:是,N:否“);
????????????????????????????????????input?=?Console.ReadLine();
????????????????????????????????????break;
????????????????????????????????}
????????????????????????????}
????????????????????????}
????????????????????}?while?(input?==“Y“);
????????????????????left_people.AddRa
評論
共有 條評論