gpt4 book ai didi

c# - 寻找类(class)指导

转载 作者:太空宇宙 更新时间:2023-11-03 13:50:57 27 4
gpt4 key购买 nike

<分区>

我目前正在做一个项目,我被要求为一个小企业(在本例中是一个小电影院)制作一个程序,我可以在其中记录和打印各种产品和客户的收据。

到目前为止,我拥有的是一系列记录客户想要订购什么的代码。

我如何着手创建另一个类来存储和计算价格并将收据的样子打印到控制台?

我不是要答案,只是一些指导。

namespace RecieptApp
{
class Reciept
{
public void Main()
{
double DoubleDiscount;
int IntFoodOrdered;
int IntDrinkOrdered;
double DoubleFoodSize;
double DoubleDrinkSize;
int ACustomer;
int BCustomer;
string CustomerDescription;
string FoodDescription;
string DrinkDescription;

Console.Write("How many adults: ");
ACustomer = Console.Read();
Console.Write("How many kids: ");
BCustomer = Console.Read();

while (true)
{
Console.Write("Are you a government employee, current or retired military, or classified disabled? (Please answer yes or no) :");
string input1 = Console.ReadLine();
if (input1 == "yes")
{
DoubleDiscount = .15;
CustomerDescription = "Special Discount";
}
else
{
break;
}
}

while (true)
{
Console.WriteLine("Would you like to order some popcorn?");
string FoodInput1 = Console.ReadLine();
if (FoodInput1 == "yes")
{
Console.WriteLine("How many would you like?");
int.TryParse(Console.ReadLine(), out IntFoodOrdered);
while (true)
{
Console.WriteLine("And would you like that in small or large?");
string FoodInput2 = Console.ReadLine();
if (FoodInput2 == "small")
{
DoubleFoodSize = 3.75;
FoodDescription = "S";
}
else
{
DoubleFoodSize = 6.75;
FoodDescription = "L";
}
}
}
else
{
break;
}
}

while (true)
{
Console.WriteLine("Would you like to order a drink?");
string DrinkInput1 = Console.ReadLine();
if (DrinkInput1 == "yes")
{
Console.WriteLine("How many would you like?");
int.TryParse(Console.ReadLine(), out IntDrinkOrdered);
while (true)
{
Console.WriteLine("And Would you like that in small or large?");
string DrinkInput2 = Console.ReadLine();
if (DrinkInput2 == "small")
{
DoubleDrinkSize = 2.75;
DrinkDescription = "S";
}
else
{
DoubleDrinkSize = 5.75;
DrinkDescription = "L";
}
}

}
}
//This is where the other class would go in
//I just dont know how to go about it so that it would minimized the amount of code I have //to write

RecieptList Items = new RecieptList();

Items.AddProduct(ACustomer);
Items.AddProduct(BCustomer);
Items.AddProduct(CustomerDescription);
Items.AddProduct(FoodDescription);
Items.AddProduct(DrinkDescription);

}
}
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com