This document defines a Book class with properties and methods to manage book inventory. The Book class stores book identifier, author, title, purchase price, sale price, and inventory as private fields. It includes public properties to get and set these fields. Static methods are included to initialize sample book data and retrieve all books. Instance methods allow adding, updating, and deleting book objects from an ArrayList.
This document defines a Book class with properties and methods to manage book inventory. The Book class stores book identifier, author, title, purchase price, sale price, and inventory as private fields. It includes public properties to get and set these fields. Static methods are included to initialize sample book data and retrieve all books. Instance methods allow adding, updating, and deleting book objects from an ArrayList.
This document defines a Book class with properties and methods to manage book inventory. The Book class stores book identifier, author, title, purchase price, sale price, and inventory as private fields. It includes public properties to get and set these fields. Static methods are included to initialize sample book data and retrieve all books. Instance methods allow adding, updating, and deleting book objects from an ArrayList.
Private bookIdentifier As String Private bookAuthor As String Private bookTitle As String Private bookPurchasePrice As Decimal Private bookSalePrice As Decimal Private bookInventory As Integer
Public Property BookID() As String
Get Return bookIdentifier End Get Set(ByVal value As String) bookIdentifier = value End Set End Property
Public Property Author() As String
Get Return bookAuthor End Get Set(ByVal value As String) bookAuthor = value End Set End Property
Public Property Title() As String
Get Return bookTitle End Get Set(ByVal value As String) bookTitle = value End Set End Property
Public Property PurchasePrice() As Decimal
Get Return bookPurchasePrice End Get Set(ByVal value As Decimal) bookPurchasePrice = value End Set End Property
Public Property SalePrice() As Decimal
Get Return bookSalePrice End Get Set(ByVal value As Decimal) bookSalePrice = value End Set End Property
Public Property Inventory() As Integer
Get Return bookInventory End Get Set(ByVal value As Integer) bookInventory = value End Set End Property
Public Shared Sub Initialize()
books.Add(New clsBook("1111111111", "C.S. Lewis", _ "The Lion, The Witch, and the Wardrobe", 350, 100, 1)) books.Add(New clsBook("2222222222", "J.R.R. Tolkien", _ "The Return of the King", 350, 100, 1)) books.Add(New clsBook("3333333333", "J.K. Rowling", _ "Harry Potter and the Deathly Hallows", 350, 100, 1)) End Sub Public Shared Function GetAll() As ArrayList Return books End Function
Public Sub New(ByVal aBookID As String, ByVal anAuthor As String, _
ByVal aTitle As String, ByVal aPurchasePrice As Decimal, ByVal _ aSalePrice As Decimal, ByVal anInventory As Integer) bookIdentifier = aBookID bookAuthor = anAuthor bookTitle = aTitle bookPurchasePrice = aPurchasePrice bookSalePrice = aSalePrice bookInventory = anInventory End Sub
Public Sub New()
End Sub
Public Sub Add()
books.Add(Me) End Sub
Public Sub Update()
Dim index As Integer Do Until books(index).BookId.Equals(Me.BookID) index = index + 1 Loop books(index) = Me End Sub