Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Class Book

Private String title


Private String author
Private String publisher
Private Integer copiesSold

Public Module Constructor(String bookTitle, String bookAuthor, String


bookPublisher, Integer soldCopies)
Set title = bookTitle
Set author = bookAuthor
Set publisher = bookPublisher
Set copiesSold = soldCopies
End Module

// Accessor methods
Public Function getTitle() As String
Return title
End Function

Public Function getAuthor() As String


Return author
End Function

Public Function getPublisher() As String


Return publisher
End Function

Public Function getCopiesSold() As Integer


Return copiesSold
End Function

// Mutator methods
Public Module setTitle(String bookTitle)
Set title = bookTitle
End Module

Public Module setAuthor(String bookAuthor)


Set author = bookAuthor
End Module

Public Module setPublisher(String bookPublisher)


Set publisher = bookPublisher
End Module

Public Module setCopiesSold(Integer soldCopies)


Set copiesSold = soldCopies
End Module
End Class
Class Book

-Title: String
- Author: String
- Publisher: String
-copiesSold: Integer
+Constructor(bookTitle: String,
bookAuthor: String, bookPublisher:
String, soldCopies:Integer)
getTitle(): String
+ getAuthor(): String
+ getPublisher(): String
+ getCopiesSold(): String
+ setTitle(bookTitle:String
+ setAuthor(bookAuthor: String)
+ setPublisher(bookPublisher: String)
+ setCopiesSold(soldCopies: Integer)
Class Account
Private Real balance
Private Real interestRate

Public Module Constructor(Real newBalance, Real newInterestRate)


Set balance = newBalance
Set interestRate = newInterestRate
End Module

Public Function calculateInterest() As Real


Return balance * interestRate / 100
End Function

Public Module deposit(Real amount)


Set balance = balance + amount
End Module

Public Module withdraw(Real amount)


If balance >= amount Then
Set balance = balance - amount
Else
Display "Insufficient funds."
End If
End Module

Public Function getBalance() As Real


Return balance
End Function

Public Function getInterestRate() As Real


Return interestRate
End Function

Public Module setBalance(Real newBalance)


Set balance = newBalance
End Module

Public Module setInterestRate(Real newInterestRate)


Set interestRate = newInterestRate
End Module
End Class
Account

- balance: Real
- interestRate: Real
+ Account(acctBalance: Real, intRate:
Real)
+ calculateInterest(): Real
+ deposit(amount: Real)
+ withdraw(amount: Real)
Class Pet
Private String name
Private String type
Private Integer age

Public Module Constructor(String petName, String petType, Integer petAge)


Set name = petName
Set type = petType
Set age = petAge
End Module

Public Function getName() As String


Return name
End Function

Public Function getType() As String


Return type
End Function

Public Function getAge() As Integer


Return age
End Function

Public Module setName(String petName)


Set name = petName
End Module

Public Module setType(String petType)


Set type = petType
End Module

Public Module setAge(Integer petAge)


Set age = petAge
End Module
End Class
Pet

- name: String
- type: String
- age: Integer
+ Pet(petName: String, petType: String,
petAge: Integer)
+ getName(): String
+ getType(): String
+ getAge(): Integer
+ setName(petName: String)
+ setType(petType: String)
+ setAge(petAge: Integer)

You might also like