Skip to content

ashishkarki/SecretSanta

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SECRET SANTA PROJECT (Ashish Karki)


Implementation

  1. ISecretSanta interface is used as a blueprint to implement two simple algorithms. There are two class files named: SimplePairing and ShufflePairing, both of which implement ISecretSanta. Each class file has their version of generateAssignments() method.
  2. Class SimplePairing uses Random class from Java to randomly choose an assignment/assignee/giftee for a particular participant.
  3. Class ShufflePairing uses Collection.shuffle() to shuffle assignmentsList. AssignmentsList is simply a ArrayList copy of participants array.
  4. Both implementations also ensures that:
    • No participant is same as his/her assignee.
    • The participants and their assignees are unique.
    • It also logically follows that all the assignments are from the list of passed participants.
  5. A factory class called SecretSantaFactory is also defined. This class has a static factory method that is responsible for creating and returning one of the Secret Santa concrete classes. Using such design has the advantage of choosing any specific implementation as per requirement. The JUnit test class also utilizes this factory method to test the current implementation.
    1. Finally, the class "SecretSantaDemo" contains main method and uses our factory to choose and run a particular algorithm.

Unit Testing

  1. Unit testing is performed using JUnit framework.
  2. A single test class is kept in the package santaProjectTests within the source folder. The test class is called SecretSantaTest. SecretSantaTest contains three different tests to check for the following cases:
    • No participant is same as his/her assignment.
    • The assignments are not simple left or right rotation of the participants.
    • All assignments are unique, that is, no two assignees are the same.

9/02/2014 Added this line as a testing of using EGIT plugin in Eclipse Luna. (#Cerner #DevAcademy)

About

Implementing secret santa draw with given specs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages