Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Lab1 - #10.3
- myInteger
- int value
- getValue
- myInteger(int value)
- isEven(), isOdd(), isPrime()
- static isEven(num), isOdd(num), isPrime(num)
- static isEven(myInteger)
- -=-=-=-=-=-=-=-=-=--=-==---=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-==-=-=-=-=-=-=-==-=--=-=-==-=-
- public class myInteger {
- private int value;
- public int getValue() {
- return value;
- }
- public void setValue(int value) {
- this.value = value;
- }
- public myInteger(int value) {
- super();
- this.value = value;
- }
- public static boolean isEven(int num){
- if((num % 2) == 0)
- return true;
- else
- return false;
- }
- public boolean isEven(){
- return myInteger.isEven(value);
- }
- public static boolean isEven(myInteger myint){
- return myInteger.isEven(myint.value);
- }
- public boolean isOdd(){
- return !isEven();
- }
- public static void main(String[] args) {
- myInteger myint7 = new myInteger(7);
- System.out.println("Is " + myint7.getValue() + " even? "+ myint7.isEven());
- }
- }
- //Add Primes, Equals And Odds! Prime: for num from to to value/2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement