fork download
  1. class myInteger {
  2. private int n;
  3. private boolean flag;
  4. private myInteger fizzbuzzgizz(int m, String mes) {
  5. if (this.n % m == 0) {
  6. this.flag = false;
  7. System.out.print(mes);
  8. }
  9. return this;
  10. }
  11.  
  12. public myInteger(int n) { this.n = n; flag = true; }
  13. public myInteger fizz() { return this.fizzbuzzgizz(3, "Fizz"); }
  14. public myInteger buzz() { return this.fizzbuzzgizz(5, "Buzz"); }
  15. public myInteger gizz() { return this.fizzbuzzgizz(7, "Gizz"); }
  16. public void endl() {
  17. if (flag == true)
  18. System.out.println(this.n);
  19. else
  20. System.out.println();
  21. }
  22. }
  23.  
  24. public class Main {
  25. public static void main(String[] args) {
  26.  
  27. new myInteger(1).fizz().buzz().gizz().endl();
  28. new myInteger(3).fizz().buzz().gizz().endl();
  29. new myInteger(5).fizz().buzz().gizz().endl();
  30. new myInteger(7).fizz().buzz().gizz().endl();
  31. new myInteger(15).fizz().buzz().gizz().endl();
  32. new myInteger(21).fizz().buzz().gizz().endl();
  33. new myInteger(35).fizz().buzz().gizz().endl();
  34. new myInteger(105).fizz().buzz().gizz().endl();
  35. new myInteger(997).fizz().buzz().gizz().endl();
  36. }
  37. }
  38. /* end */
  39.  
Success #stdin #stdout 0.03s 245632KB
stdin
Standard input is empty
stdout
1
Fizz
Buzz
Gizz
FizzBuzz
FizzGizz
BuzzGizz
FizzBuzzGizz
997