Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package DPTest
- trait Account {
- def account_type: String
- def getType(): String
- def printHistory() = {}
- }
- class CheckingAccount(accountType: String) extends Account{
- override def printHistory(): Unit = {
- print("Test " + this.getType() + " history")
- }
- override def getType(): String = {
- account_type
- }
- override def account_type: String = accountType
- }
- trait OnlineAccount extends Account{
- abstract override def getType(): String = {
- "online " + super.getType()
- }
- }
- object Demo extends App {
- val c = new CheckingAccount("checking account") with OnlineAccount
- c.printHistory()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement