Untitled

mail@pastecode.io avatar
unknown
plain_text
17 days ago
1.5 kB
3
Indexable
Never
import java.util.* ;

// task 1 starts
abstract class student{

    abstract void take_exam();
}
class phdStudent extends student{
    void take_exam(){
        System.out.println("PHD student takes FINAL DEFENSE EXAM");
    }
}
class gradStudent extends student{
    void take_exam(){
        System.out.println("Grad student takes WRITTEN PAPER EXAM");
    }
}
// task 1 ends



// task 2 starts
interface movvablePoint{
    void moveUp();
    void moveDown();
    void moveLeft();
    void moveRight();
}
interface movvableCircle{
    void moveUp();
    void moveDown();
    void moveLeft();
    void moveRight();
}


class Movvable implements movvableCircle, movvablePoint{
    int up=0, down=0, left=0, right=0;
    public void moveUp(){
        System.out.println("Up is: " + ++up);
    }
    public void moveDown(){
        System.out.println("Down is: " + ++down);
    }
    public void moveLeft(){
        System.out.println("Left is: " + ++left);
    }
    public void moveRight(){
        System.out.println("Right is: " + ++right);
    }

}
// task 2 ends



public class Main {
    public static void main(String[] args) {

        //task 1
        student st = new phdStudent();
        st.take_exam();
        student st2 = new gradStudent();
        st2.take_exam();

        //task 2
        Movvable mov = new Movvable();
        mov.moveUp();
        mov.moveUp();
        mov.moveDown();
        mov.moveLeft();
        mov.moveRight();

        //task 3


    }
}
Leave a Comment