- 分享
- 0
- 人气
- 30
- 主题
- 29
- 帖子
- 1850
- UID
- 81817
- 积分
- 1487
- 阅读权限
- 18
- 注册时间
- 2007-6-12
- 最后登录
- 2018-4-14
- 在线时间
- 12123 小时
|
Public Class formQ2
Private Sub btnOrder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOrder.Click
Dim amount As Double
Dim shape = TotalShape()
Dim flavour = TotalFlavour()
Dim topping = TotalTopping()
Dim delivery = TotalDelivery(amount)
Dim befDiscount = TotalBeforeDiscount(shape, flavour, topping, delivery)
Dim aftDiscount = TotalDiscount(befDiscount)
txtTotal.Text = ("$" & aftDiscount)
End Sub
Function TotalShape() As Double
Dim price As Double = 0
If rdbRound.Checked Then
price = 15
txtShape.Text = "Round"
Else
price = 20
txtShape.Text = "Square"
End If
Return price
End Function
Function TotalFlavour() As Double
Dim price As Double = 0
If chkLemon.Checked Then
price += 3
txtFlavour.Text = "Lemon"
End If
If chkVanilla.Checked Then
price += 8
txtFlavour.Text = "Vanilla"
End If
Return price
End Function
Function TotalTopping() As Double
Dim price As Double = 0
If chkFruits.Checked Then
price += 6
txtTopping.Text = "Fruits"
End If
If chkCaramel.Checked Then
price += 10
txtTopping.Text = "Caramel"
End If
Return price
End Function
Function TotalDelivery(ByVal amount) As Double
Dim price As Double = 0
If chkDelivery.Checked Then
price += 5
End If
Return price
End Function
Function TotalBeforeDiscount(ByVal shape, ByVal flavour, ByVal topping, ByVal delivery) As Double
Dim price As Double = 0
price = shape + flavour + topping + delivery
Return price
End Function
Function TotalDiscount(ByVal befDiscount) As Double
Dim price As Double = 0
If chkDelivery.Checked Then
If befDiscount >= 30 Then
price = befDiscount - (befDiscount * 0.2)
Else
price = befDiscount
End If
Else
price = befDiscount
End If
Return price
End Function
Sub ClearAll()
rdbRound.Checked = False
rdbSquare.Checked = False
chkLemon.Checked = False
chkVanilla.Checked = False
chkFruits.Checked = False
chkCaramel.Checked = False
chkMember.Checked = False
chkDelivery.Checked = False
txtName.Clear()
txtAddress.Clear()
txtFlavour.Clear()
txtShape.Clear()
txtTopping.Clear()
txtTotal.Clear()
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
ClearAll()
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
End Class |
|