Advertisement
nein_yards

PM Task 3 2021

Jan 9th, 2021
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. Class Tool
  2. Private name As String
  3. Private cost As Decimal
  4. Private imageFileName As String
  5. Sub New(name As String, cost As Decimal, imageFileName As String)
  6. Me.name = name
  7. Me.cost = cost
  8. Me.imageFileName = imageFileName
  9. End Sub
  10.  
  11. Function getName()
  12. Return name
  13. End Function
  14. Sub setName(name)
  15. Me.name = name
  16. End Sub
  17. Function getCost()
  18. Return cost
  19. End Function
  20. Sub setCost(cost)
  21. Me.cost = cost
  22. End Sub
  23. Function getImageFileName()
  24. Return imageFileName
  25. End Function
  26. Sub setImageFileName(imageFileName)
  27. Me.imageFileName = imageFileName
  28. End Sub
  29.  
  30. End Class
  31. Class Shelf
  32. Public position As Integer
  33. Public tools(10) As Tool
  34. Private nextToolIndex As Integer
  35.  
  36. Sub New(position As Integer)
  37. Me.position = position
  38. nextToolIndex = 0
  39. End Sub
  40.  
  41. Sub addTool(tool As Tool)
  42. If nextToolIndex = 10 Then
  43. Console.WriteLine("Error: Shelf is full")
  44. Else
  45. tools(nextToolIndex) = tool
  46. End If
  47. nextToolIndex += 1
  48. End Sub
  49.  
  50. End Class
  51.  
  52. Sub outputToolsFromShelf(shelf As Shelf)
  53. Dim i As Integer = 0
  54. While Not shelf.tools(i) Is Nothing
  55. Console.WriteLine("Tool name: " & shelf.tools(i).getName)
  56. Console.WriteLine("Cost: " & shelf.tools(i).getCost)
  57. Console.WriteLine()
  58. i += 1
  59. End While
  60. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement