This is not an homework. But an practice to understand what are the best practices to design , implement and unit test a particular scenario and so discussion explaining why a particular approach was taken as compared to other would be really helpful from understanding point of view to gain better understanding of how to approach and deal with similar situations.
How to approach following scenario from design, implementation and unit testing perspective.
Scenario
A speaker and a listener communicate with each other. The speaker can present emotions to the listener: smile,anger, courtesy, joke, fury, etc.
The listener gives a proper response for each communication (say something, attack, defense, ignore, etc.).
Questions
- What will be the listener objects’s reaction rules ?
- How would this be designed using UML and implemented by simulating it using text outputs ?
- What would be the JUnit test case for the checking proper implementation of this scenario ?
Following steps are extremely important for any development.
Requirement gathering
Freezing and documenting exact requirements. Drafting exact use cases help a lot.
Design
Designing the solution. Here different approaches can be chosen depending upon the nature of project.
For a long term project with short spurts of deliverables and reviews, an incremental pattern helps a lot.
Here you design your application in thorough. The releases cycles are longer. Every feature is completed first and then delivered.
Using UML following diagrams are important.
Should list all classes in detail. Use of Interface, Abstract classes, helper classes, Third Party APIs can be detailed here.
Should list the flow of actions for all listed use cases in project.
Use of appropriate design patterns should be included here. Test cases should be drafted matching the use cases, generally in relation like 1 or more test cases per use case.
There actually is a lot to describe here. What I have provided is the approach that should be taken while implementing the project.
Considering your application, breaking it down to different pieces can help design it simpler. On a broad level I can think of following pieces.