编程实现一个处理单价为5角钱的饮料的自动售货机软件,并用因果法设计测试用例并实

这个简单嘛.....

Dim summoney As Integer = 100

Public Sub Test(ByVal money As Integer, ByVal options As String)

' 若投入5角钱或1元硬币,押下〖橙汁〗或〖啤酒〗的按钮,则相应的饮料就送出来

'若售货机没有零钱找,则一个显示〖零钱找完〗的红灯亮,这时投入1元硬币并押下按钮后,饮料不送出来而且1元硬币也退出来;

'若有零钱找,则显示〖零钱找完〗的红灯灭,在送出饮料的同时退还5角硬币。”

Dim fiveTea As String = "茶"

Dim oneCoffee As String = "咖啡"

Response.Write("欢迎光临,请投币/并选择物品!")

Select Case CType(options, String)

Case options = fiveTea

Response.Write("您选择的是茶!$5")

If money = 5 Then

Response.Write("您的物品" & fiveTea & "已购买成功!谢谢光临")

ElseIf money < 5 Then

Response.Write("不起,钱不够,请投币!")

ElseIf money &gt; 5 Then

Dim s As Integer

If sumMoney > money Then

s = money - 5

Response.Write("您的物品" & fiveTea & "已购买成功!应找您" & s & "元")

Else

Response.Write("对不起,无法找您钱!谢谢光临!请收好您的钱" & money & "")

End If

End If

Case options = oneCoffee

Response.Write("您选择的是咖啡!$1")

If money = 1 Then

Response.Write("您的物品" & oneCoffee & "已购买成功!谢谢光临")

ElseIf money < 1 Then

Response.Write("对不起,钱不够,请投币!")

ElseIf money > 1 Then

Dim s As Integer

If sumMoney > money Then

s = money - 1

Response.Write("您的物品" & oneCoffee & "已购买成功!应找您" & s & "元")

Else

Response.Write("对不起,无法找您钱!谢谢光临!请收好您的钱" & money & "")

End If

End If

End Select

sumMoney += sumMoney

End Sub

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。