- public class Game {
-
- public String Screen;
- public String JoyStick;
- public int Power;
-
- public Game(String Screen,String JoyStick, int Power){
- this.Screen = Screen;
- this.JoyStick = JoyStick;
- this.Power = Power;
- }
-
- public void Open(){
-
- System.out.println("主機開機中");
- }
-
- public void Close(){
- System.out.println("主機關機中");
- }
- }
複製代碼- public class PS4 extends Game{
- public PS4(String Screen, String JoyStick, int Power){
- super(Screen, JoyStick, Power);
- }
- }
複製代碼- public class Main {
- public static void main(String[] args) {
- PS4 game = new PS4("5k螢幕","雙把手",110);
- game.Open();
- game.Close();
- }
- }
複製代碼 |