Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CandyDistributor{
- private boolean fair;
- private int currentTopic=0;
- private int amount=1;
- public CandyDistributor(boolean fair){
- this.fair=fair;
- }
- public void nextCandy(){
- if(currentTopic==0){
- System.out.println(amount+" for you");
- if(fair){
- currentTopic=amount-1;
- }
- }else{
- System.out.println(currentTopic+" for me");
- if(currentTopic==amount){
- currentTopic=-1;
- amount++;
- }
- }
- currentTopic++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement