因此,我已经尝试了很长一段时间的工作是将表单上选定的单选按钮连接到列表框中,以便将其作为收据读出。我将一个变量receipt 声明为一个空字符串,我很好奇如何使用选中的单选按钮填充receipt 变量。如果需要,我可以提供我拥有的代码,尽管我不确定它是否会有所帮助。
代码如下
public class Order
{
public string[] pizzaChoice = new
string[] {"Plain Slice", "Medium Plain", "Large Plain", "White Slice", "Medium White", "Large White",
"Roar Slice", "Roar Medium", "Roar Large", "BBQ Slice", "BBQ Medium", "BBQ Large",
"Cheeseburger Slice", "Cheeseburger Medium", "Cheeseburger Large", "Buffalo Slice", "Buffalo Medium", "Buffalo Large",
"The Works Slice", "The Works Medium", "The Works Large"};
public decimal[] pizzaChoicePrice = new decimal[] {1.50m, 8.00m, 10.00m, 1.75m, 9.00m, 12.00m,
2.00m, 9.00m, 12.00m, 2.00m, 9.00m, 12.00m,
2.00m, 9.00m, 12.00m, 2.00m, 9.00m, 12.00m,
2.50m, 10.00m, 13.00m};
private string pizza;
private string drink;
private string specialRequest;
private decimal pizzaPrice;
private decimal drinkPrice;
public Order()
{
pizza = "";
specialRequest = "";
drinkPrice = 0;
pizzaPrice = 0;
}
public string Pizza
{
get
{
return pizza;
}
set
{
pizza = value;
SetPizzaPrice();
}
}
public string SpecialRequests
{
get
{
return specialRequest;
}
set
{
specialRequest = value;
}
}
public string Drink
{
get
{
return drink;
}
set
{
drink = value;
SetDrinkPrice();
}
}
public decimal PizzaPrice
{
get
{
return pizzaPrice;
}
}
public decimal DrinkPrice
{
get
{
return drinkPrice;
}
}
public void SetPizzaPrice()
{
for (int i = 0; i < pizzaChoice.Length; i++)
{
if (pizzaChoice[i] == pizza)
{
pizzaPrice = pizzaChoicePrice[i];
}
}
}
public void SetDrinkPrice()
{
switch (drink)
{
case "Small Water":
case "Medium Water":
case "Large Water":
drinkPrice = 0.00m;
break;
case "Small Fountain Soda":
case "Can of Soda":
drinkPrice = 0.75m;
break;
case "Medium Fountain Soda":
drinkPrice = 1.25m;
break;
case "Large Fountain Soda":
case "Large Iced Tea/Lemonade/Juice":
drinkPrice = 2.00m;
break;
case "20 oz Bottled Soda":
drinkPrice = 1.75m;
break;
case "2 Liter Bottled Soda":
drinkPrice = 2.50m;
break;
case "12 oz Iced Tea/Lemonade/Juice":
drinkPrice = 1.00m;
break;
case "24 oz Iced Tea/Lemonade/Juice":
drinkPrice = 1.50m;
break;
}
}
public decimal TotalBeforeTax()
{
return pizzaPrice + drinkPrice;
}
}
}