Add OOP/Java/Lab/Week6/Game/Gamer.java

This commit is contained in:
Aadit Agrawal 2024-09-14 01:52:58 +05:30
parent 6982f92ddb
commit d12bfe4593

View 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();
}
}