During lecture, we simulated a
FileLogger trait using
println(), which, obviously, does not input into a file. Implement a real Scala trait—based on our lecture—that logs to a file.
During lecture, we discussed an object-level mix-in that logs both to a file and to the console:
val acct3 = new SavingsAccount with ConsoleLogger with FileLogger
TimestampLoggerin the list of traits?
Consider the following Scala code:
var acct: SavingsAccount = new SavingsAccount val acct2: SavingsAccount = new SavingsAccount with FileLogger
acct2? Explain this relationship.
acct2refer to the object referred by
acct? Why or why not?
acctrefer to the object referred by
acct2? Why or why not?
Explain the difference between the
equals. Can you think of a scenario where this is not true? Explain the use case.