Advertisement
RazorBlade57

Hw due

Jan 29th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. Lab1 - #10.3
  2. myInteger
  3. int value
  4. getValue
  5. myInteger(int value)
  6. isEven(), isOdd(), isPrime()
  7. static isEven(num), isOdd(num), isPrime(num)
  8. static isEven(myInteger)
  9. -=-=-=-=-=-=-=-=-=--=-==---=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-==-=-=-=-=-=-=-==-=--=-=-==-=-
  10.  
  11.  
  12. public class myInteger {
  13.  
  14. private int value;
  15.  
  16. public int getValue() {
  17. return value;
  18. }
  19.  
  20. public void setValue(int value) {
  21. this.value = value;
  22. }
  23.  
  24. public myInteger(int value) {
  25. super();
  26. this.value = value;
  27. }
  28.  
  29. public static boolean isEven(int num){
  30. if((num % 2) == 0)
  31. return true;
  32. else
  33. return false;
  34. }
  35.  
  36. public boolean isEven(){
  37. return myInteger.isEven(value);
  38. }
  39.  
  40. public static boolean isEven(myInteger myint){
  41. return myInteger.isEven(myint.value);
  42. }
  43.  
  44. public boolean isOdd(){
  45. return !isEven();
  46. }
  47.  
  48. public static void main(String[] args) {
  49.  
  50. myInteger myint7 = new myInteger(7);
  51.  
  52. System.out.println("Is " + myint7.getValue() + " even? "+ myint7.isEven());
  53.  
  54. }
  55.  
  56. }
  57.  
  58. //Add Primes, Equals And Odds! Prime: for num from to to value/2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement