CSharp OOP Advanced Communication and Events Lab
CSharp OOP Advanced Communication and Events Lab
This document defines the exercises for C# OOP Advanced" course @ Software University.
You can check your solutions here: Judge .
interface IHandler
o void Handle(LogType, String)
o void SetSuccessor(Handler)
Solution
Create enum LogType
© Software University Foundation. This work is licensed under the CC-BY-NC-SA license.
© Software University Foundation. This work is licensed under the CC-BY-NC-SA license.
3. Command
Create a Command Pattern Executor and provide:
interface ICommand
o void Execute()
interface IExecutor
o void ExecuteCommand(Command command)
Concrete Commands
o TargetCommand with constructor (Attacker, Target)
o AttackCommand with constructor (Attacker)
Hints
Create the interfaces
Each new command should implement ICommand, so it can be executed by the IExecutor
© Software University Foundation. This work is licensed under the CC-BY-NC-SA license.
Hints
Implement Group implements IAttackGroup - this will be the concrete mediator
x
Create some group commands, following the logic from the previous problem
Test the mediator
© Software University Foundation. This work is licensed under the CC-BY-NC-SA license.
interface IObserver
o Update(int)
If a Target dies, it should send reward to all of its Observers
Hints
Create the interfaces
IAttacker should be the IObserver
* Dragon should be the ISubject - (the easiest way is to make ITarget extends ISubject, but this is
violation of the Interface Segregation Principle). The better solution is to create a new interface
ObservableTarget and implement both ITarget and IObserver.
© Software University Foundation. This work is licensed under the CC-BY-NC-SA license.