Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. public class CandyDistributor{
  2. private boolean fair;
  3. private int currentTopic=0;
  4. private int amount=1;
  5. public CandyDistributor(boolean fair){
  6. this.fair=fair;
  7.  
  8. }
  9. public void nextCandy(){
  10. if(currentTopic==0){
  11. System.out.println(amount+" for you");
  12. if(fair){
  13. currentTopic=amount-1;
  14. }
  15. }else{
  16. System.out.println(currentTopic+" for me");
  17. if(currentTopic==amount){
  18. currentTopic=-1;
  19. amount++;
  20. }
  21. }
  22. currentTopic++;
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement