Add OOP/Java/Lab/Week6/Game/Gamer.java
This commit is contained in:
parent
6982f92ddb
commit
d12bfe4593
33
OOP/Java/Lab/Week6/Game/Gamer.java
Normal file
33
OOP/Java/Lab/Week6/Game/Gamer.java
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
class Game {
|
||||||
|
|
||||||
|
void type() {
|
||||||
|
System.out.println("Indoor & outdoor games");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Cricket extends Game {
|
||||||
|
|
||||||
|
void type() {
|
||||||
|
System.out.println("Cricket is an outdoor game");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Chess extends Game {
|
||||||
|
|
||||||
|
void type() {
|
||||||
|
System.out.println("Chess is an indoor game");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Gamer {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Game game = new Game();
|
||||||
|
Game cricket = new Cricket();
|
||||||
|
Game chess = new Chess();
|
||||||
|
|
||||||
|
game.type();
|
||||||
|
cricket.type();
|
||||||
|
chess.type();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user