Untitled
unknown
plain_text
2 years ago
1.5 kB
8
Indexable
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
}
}Editor is loading...
Leave a Comment