computer2019623

ldzsl發表於2021-09-09
package altashna.java.computer2019623;

public class OnLoad {
    public static void main(String[] args) {
        Computer c = new Computer("apple", "block", "12562.50", "程式正在執行中");
        c.open();
        c.clsoe();
        c.stop();
    }
}

class Computer {
    String Name;
    String Color;
    String Price;
    String State;

    //初始化無引數狀態  Computer c = new Compute();
    public Computer() {
        System.out.printf("");
    }

    //初始化有引數狀態 Computer c = new Computer("apple","block","12562.50","程式正在執行中");
    public Computer(String Name, String Color, String Price, String State) {
        this.Name = Name;
        this.Color = Color;
        this.Price = Price;
        this.State = State;
    }

    void open() {
        System.out.printf("開啟");
    }

    void clsoe() {
        System.out.printf("關閉");
    }

    void stop() {
        System.out.printf("睡覺");
    }
}

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/2325/viewspace-2823185/,如需轉載,請註明出處,否則將追究法律責任。