Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Class Tool
- Private name As String
- Private cost As Decimal
- Private imageFileName As String
- Sub New(name As String, cost As Decimal, imageFileName As String)
- Me.name = name
- Me.cost = cost
- Me.imageFileName = imageFileName
- End Sub
- Function getName()
- Return name
- End Function
- Sub setName(name)
- Me.name = name
- End Sub
- Function getCost()
- Return cost
- End Function
- Sub setCost(cost)
- Me.cost = cost
- End Sub
- Function getImageFileName()
- Return imageFileName
- End Function
- Sub setImageFileName(imageFileName)
- Me.imageFileName = imageFileName
- End Sub
- End Class
- Class Shelf
- Public position As Integer
- Public tools(10) As Tool
- Private nextToolIndex As Integer
- Sub New(position As Integer)
- Me.position = position
- nextToolIndex = 0
- End Sub
- Sub addTool(tool As Tool)
- If nextToolIndex = 10 Then
- Console.WriteLine("Error: Shelf is full")
- Else
- tools(nextToolIndex) = tool
- End If
- nextToolIndex += 1
- End Sub
- End Class
- Sub outputToolsFromShelf(shelf As Shelf)
- Dim i As Integer = 0
- While Not shelf.tools(i) Is Nothing
- Console.WriteLine("Tool name: " & shelf.tools(i).getName)
- Console.WriteLine("Cost: " & shelf.tools(i).getCost)
- Console.WriteLine()
- i += 1
- End While
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement