Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Class Str
- Private str As String
- Sub New(str As String)
- Me.str = str
- End Sub
- Sub setString(str As String)
- Me.str = str
- End Sub
- Sub printString()
- Console.WriteLine(str.ToUpper())
- End Sub
- End Class
- Class Rectangle
- Private length As Decimal
- Private width As Decimal
- Sub New(length As Integer, width As Integer)
- Me.length = length
- Me.width = width
- End Sub
- Function getArea()
- Return length * width
- End Function
- End Class
- Class Circle
- Private radius As Decimal
- Sub New(radius As Decimal)
- Me.radius = radius
- End Sub
- Function getArea()
- Return 3.14 * radius * radius
- End Function
- Function getCircumference()
- Return 2 * 3.14 * radius
- End Function
- End Class
- Class Operation
- Private a As Integer
- Private b As Integer
- Sub New(a As Integer, b As Integer)
- Me.a = a
- Me.b = b
- End Sub
- Function power()
- Dim multTotal As Integer = 1
- For i = 1 To b
- multTotal *= a
- Next
- Return multTotal
- End Function
- End Class
- Class Customer
- Private customerNumber As Integer
- Private customerName As String
- Private price, qty, discount, totalPrice, netPrice As Integer
- 'note, all currency in lowest denomination (eg cents)
- 'to prevent floating point rounding error
- Sub New(customerNumber As Integer, customerName As String)
- Me.customerNumber = customerNumber
- Me.customerName = customerName
- qty = 0
- price = 0
- discount = 0
- totalPrice = 0
- netPrice = 0
- End Sub
- Sub calDiscount()
- totalPrice = price * qty
- If totalPrice >= 50000 Then
- discount = totalPrice * 25 * 0.01
- ElseIf totalPrice >= 25000 Then
- discount = totalPrice * 15 * 0.01
- Else
- discount = totalPrice * 10 * 0.01
- End If
- netPrice = totalPrice - discount
- End Sub
- Sub input(price, qty)
- Me.price = price
- Me.qty = qty
- calDiscount()
- End Sub
- Sub show()
- Console.WriteLine("Customer number: " & customerNumber)
- Console.WriteLine("Customr name: " & customerName)
- Console.WriteLine("Total price: " & totalPrice)
- Console.WriteLine("Discount: " & discount)
- Console.WriteLine("Net price: " & netPrice)
- End Sub
- End Class
- Sub Main()
- Dim name As Str = New Str("Taufiq")
- name.printString()
- Dim rectangle As Rectangle = New Rectangle(3, 4)
- Console.WriteLine(rectangle.getArea())
- Dim circle As Circle = New Circle(5)
- Console.WriteLine(circle.getArea)
- Console.WriteLine(circle.getCircumference)
- Dim func As Operation = New Operation(2, 3)
- Console.WriteLine(func.power())
- Dim customer As New Customer(12, "Taufiq")
- customer.input(200, 5)
- customer.show()
- Console.ReadLine()
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement