Day 4 / Apr 22 (Fri)¶
Morning Exercise¶
Exercise: Using Consumer Group
After completing the exercise, run multiple instances of your Kafka consumer application (you should have one developed already) and observe what partitions they consume. Modify the application to print out record values and partitions to the standard output (console).
Theory¶
Practice¶
Honing our skills in Object-Oriented Programming in Scala.
For every exercise do the following:
- Write tests
- Publish to Github
Exercise 1¶
Write the following classes so, when executed, use something instance-specific:
Logger
thatprint
s out a message with a log prefixSender
thatsend
s out a message with a message header
"Executed" means "called" by a "caller".
Exercise 2: Bank¶
Write a Bank
class that may have one or more Account
s.
An Account
has a balance and a number.
- You can make a deposit and a withdraw of a specified amount
- Handle insufficient funds to withdraw
- Is it enough to return a boolean value to indicate a failure?
- You can print a statement for an account
- You can close an account (which is to make a balance zero)
Define transfer
method to transfer money from one account to another (only when there is enough money).
Exercise 3: Currency Exchange¶
Define a Kantor
class with the following properties:
- A customer can open one or more currency accounts
- A customer can exchange one currency to another (between accounts) according to exchange rate table published at regular intervals
Exercise 4: Speaking Languages¶
A person can speak different languages.
Write a Person
class that can say hello
in as many languages as it knows (e.g. English, French, Polish, German).
A person can report what languages it can speak.
Two people can talk only when they speak at least one language they both can speak.