我想choice = 1
仅能被选定五倍,因此,我初步形成了一个可变的<代码>firstClass = 0,然后建立了一个可复制的firstClass < 5
。 我在担任反职务时,列入<代码>第1Class++。 然而,我认为,每当我称之为<条形码>时,第一册正在重新启用。 我如何能够防止这种情况发生? 提前感谢。
using System;
namespace Assignment7
{
class Plane
{
public static void Main(string[] args)
{
Console.WriteLine("Welcome to the Airline Reservation System.");
Console.WriteLine("Where would you like to sit?
");
Console.WriteLine("Enter 1 for First Class.");
Console.WriteLine("Enter 2 for Economy.");
CheckIn();
}
public static void CheckIn()
{
int choice = Convert.ToInt32(Console.ReadLine());
int firstClass = 0;
int economy = 0;
if (choice == 1)
{
do
{
Console.WriteLine("You have chosen a First Class seat.");
firstClass++;
CheckIn();
} while (firstClass < 5);
}
else if (choice == 2)
{
do
{
Console.WriteLine("You have chosen an Economy seat.");
economy++;
CheckIn();
} while (economy < 5);
}
else
{
Console.WriteLine("That does not compute.");
CheckIn();
}
}
}
}