南昌航空大學軟院第二次部落格

23201424-吴彦华發表於2024-06-09

一、前言

1.透過這幾次P他的大作業,加深了我對java程式設計的瞭解和熟練度。
這一段時間的學習:這一段時間主要訓練了有關java介面和多型相關方面的知識,這部分內容是Java的重要組成部分,他們共同提高了程式碼的開發效率,使得程式碼設計靈活,維護簡單,結構清晰
關於類的特性:在設計類的過程中,透過對各種類之間關係的設計,發現類具有很多特性,這些特性使得類成為物件導向程式設計中的核心概念,能夠更好地組織和管理程式碼,提高程式碼的可維護性和可擴充套件性。

2.這幾次大作業每一次迭代,都在原先的基礎上增加了一些需要考慮的東西,這需要我們對題目進行進一輪的分析和考慮,在加大題目難度的同時,也使我們更好的鍛鍊類之間的設計能力

二、設計與分析

1.7-1 答題判題程式-4

(1)該題目是答題程式的最後一次迭代,相較前幾題增加了多選題和填空題,增加了需要考慮的情況,和對半對結果的分析

(2)類的設計:

具體如類圖所示

具體設計如下:

   public int getAnswerPaperNum() {
            return AnswerPaperNum;
        }

        public void setAnswerPaperNum(int answerPaperNum) {
            AnswerPaperNum = answerPaperNum;
        }

        public String getId() {
            return Id;
        }

        public void setId(String id) {
            Id = id;
        }

        public ArrayList<Question> getQuestionArrayList() {
            return questionArrayList;
        }

        public void setQuestionArrayList(ArrayList<Question> questionArrayList) {
            this.questionArrayList = questionArrayList;
        }

        public ArrayList<Integer> getAnswerNum() {
            return AnswerNum;
        }

        public void setAnswerNum(ArrayList<Integer> answerNum) {
            AnswerNum = answerNum;
        }

        public ArrayList<String> getQuestionAnswer() {
            return QuestionAnswer;
        }

        public void setQuestionAnswer(ArrayList<String> questionAnswer) {
            QuestionAnswer = questionAnswer;
        }

        public TestPaper getTestPaper() {
            return testPaper;
        }

        public void setTestPaper(TestPaper testPaper) {
            this.testPaper = testPaper;
        }
    }

    public static class choiceQuestion extends Question{

        private ArrayList<String> result;
        public choiceQuestion(int num, String question, ArrayList<String> result) {
            super();
            this.setQuestionNum(getQuestionNum());
            this.setQuestion(getQuestion());
            this.result=result;
            this.setQuestionExist(true);
            this.setType("choice");
        }
    }

    public static class FillQuestion extends Question{
        public FillQuestion(int num, String question, String result) {
            super(num, question, result);
            this.setType("fillquestion");
        }
    }

    public static class PTA4 {
    }

    public static class Question {
        private int QuestionNum;
        private String question;
        private String result;
        private boolean isQuestionExist;
        private String type;

        public Question() {
        }

        public Question(int QuestionNum, String question, String result) {
            this.QuestionNum = QuestionNum;
            this.question = question;
            this.result = result;
            this.isQuestionExist = true;
            this.type = "normal";
        }

        public int getQuestionNum() {
            return QuestionNum;
        }

        public void setQuestionNum(int questionNum) {
            this.QuestionNum = questionNum;
        }

        public String getQuestion() {
            return question;
        }

        public void setQuestion(String question) {
            this.question = question;
        }

        public String getResult() {
            return result;
        }

        public void setResult(String result) {
            this.result = result;
        }

        public boolean isQuestionExist() {
            return isQuestionExist;
        }

        public void setQuestionExist(boolean questionExist) {
            isQuestionExist = questionExist;
        }

        public String getType() {
            return type;
        }

        public void setType(String type) {
            this.type = type;
        }
    }

    public static class Student {
        private String name;
        private String id;

        public Student(String id,String name) {
            this.name = name;
            this.id = id;
        }

        public Student() {
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }
    }

    public static class TestPaper {
        private int TestNum;
        private ArrayList<Integer> TitleNum;
        private ArrayList<Integer> TitleScore;
        private ArrayList<String>  TitleType;

        public TestPaper() {
        }

        public TestPaper(int testNum, ArrayList<Integer> titleNum, ArrayList<Integer> titleScore) {
            TestNum = testNum;
            TitleNum = titleNum;
            TitleScore = titleScore;
        }

        public int getTestNum() {
            return TestNum;
        }

        public void setTestNum(int testNum) {
            TestNum = testNum;
        }

        public ArrayList<Integer> getTitleNum() {
            return TitleNum;
        }

        public void setTitleNum(ArrayList<Integer> titleNum) {
            TitleNum = titleNum;
        }

        public ArrayList<Integer> getTitleScore() {
            return TitleScore;
        }

        public void setTitleScore(ArrayList<Integer> titleScore) {
            TitleScore = titleScore;
        }

        public ArrayList<String> getTitleType() {
            return TitleType;
        }

        public void setTitleType(ArrayList<String> titleType) {
            TitleType = titleType;
        }
    }

    public static class Type {
        private ArrayList<Integer>QuestionNum;
        private ArrayList<String>QuestionType;

        public Type(ArrayList<Integer> questionNum, ArrayList<String> questionType) {
            QuestionNum = questionNum;
            QuestionType = questionType;
        }

        public Type() {
        }

        public ArrayList<Integer> getQuestionNum() {
            return QuestionNum;
        }

        public void setQuestionNum(ArrayList<Integer> questionNum) {
            QuestionNum = questionNum;
        }

        public ArrayList<String> getQuestionType() {
            return QuestionType;
        }

        public void setQuestionType(ArrayList<String> questionType) {
            QuestionType = questionType;
        }
    }
}

此次的答題判題程式中, 選擇題的選項有多個, 正確答案也可以有多個.在這道題中,我使用了一個Arrlist去儲存題目的正確答案 在判斷答題正誤時, 應首先首先判斷學生的答案中是否存在正確答案之外的答案, 如果存在, 則答題錯誤.

然後計算正確答案中, 有幾個被學生回答到, 如果一個都沒有, 則答題錯誤; 如果存在, 但數目小於正確答案個數, 則半對; 如果數目等於正確答案個數, 則回答全對.

2.nchu-software-oop-2024-上-4:智慧家用電器系統(一)

(1)解題思路:本題需要讀入串聯電路的控制裝置與受控裝置的資訊,並透過讀入操作指令對受控裝置的檔位或狀態進行調節,從而實現對受控裝置的狀態的改變

(2)類的設計

具體類圖如圖所示

類的設計具體程式碼如下:

 public static class Switch extends ControlDevice {

        public Switch(double inputPins1, double outputPins2) {
            super(inputPins1, outputPins2);
            super.setOpen(false);
        }

        @Override
        public void ChangeOpen() {
            super.ChangeOpen();
        }

        @Override
        public double getVoltage() {
            if(isOpen()){
            return getInputPins1()-getOutputPins2();
            }else {
                return 0;
            }
        }
    }

    public static class LXcontroler extends ControlDevice{
        public LXcontroler(double inputPins1, double outputPins2) {
            super(inputPins1, outputPins2);
        }

        public LXcontroler() {
        }
    }

    public static class LightRG extends Light{
        public LightRG(ControlDevice controlDevice) {
            super(controlDevice);

        }

        @Override
        public double getBrightness() {
            if(getControlDevice().getVoltage()==0){
                setBrightness(0);
            }else {
                setBrightness(180);
            }
            return super.getBrightness();
        }
    }

    public static class LightBZ extends Light{
        public LightBZ(ControlDevice controlDevice) {
            super(controlDevice);
        }

        @Override
        public double getBrightness() {

            if(getControlDevice().getVoltage()>0&&getControlDevice().getVoltage()<=9){
                setBrightness(0);
            } else if (getControlDevice().getVoltage()>9) {
                setBrightness((getControlDevice().getVoltage()-10)*(150/210.0)+50);
            }

            return super.getBrightness();
        }
    }

    public static class Light extends Equipment{
        private double brightness;

        public Light(ControlDevice controlDevice) {
            super(controlDevice);
        }

        public double getBrightness() {
            return brightness;
        }

        public void setBrightness(double brightness) {
            this.brightness = brightness;
        }
    }

    public static class FDcontroler extends ControlDevice{
        public FDcontroler(double inputPins1, double outputPins2) {
            super(inputPins1, outputPins2);
        }

        public FDcontroler() {
        }
        private int i=0;

        public int getI() {
            return i;
        }

        public void setI(int i) {
            this.i = i;
        }

        public double[] getGearsArray() {
            return gearsArray;
        }

        public void setGearsArray(double[] gearsArray) {
            this.gearsArray = gearsArray;
        }

        private double[] gearsArray={0,0.3,0.6,0.9};

        public void addGears() {
            if(i<=2){
                i++;
            super.setGears(gearsArray[i]);
            }
        }
        public void delGears(){
            if(i>=1){
            i--;
            super.setGears(gearsArray[i]);
            }
        }
    }

    public static class Fans extends Equipment{
        private double speed;
        public Fans(ControlDevice controlDevice) {
            super(controlDevice);

        }

        public double getSpeed() {
            if(getControlDevice().getVoltage()<80){
                setSpeed(0);
            } else if (getControlDevice().getVoltage()<=150) {
                setSpeed(80+(getControlDevice().getVoltage()-80)*(360-80)/70);
            } else if (getControlDevice().getVoltage()>150) {
                setSpeed(360);
            }
            return speed;
        }

        public void setSpeed(double speed) {
            this.speed = speed;
        }
    }

    public static class Equipment {
        private ControlDevice controlDevice;
        private double gears;
        private double voltage;
        private String name;
        private String num;
        private boolean ispin1=false;
        private boolean ispin2=false;

        public boolean isIspin1() {
            return ispin1;
        }

        public void setIspin1(boolean ispin1) {
            this.ispin1 = ispin1;
        }

        public boolean isIspin2() {
            return ispin2;
        }

        public void setIspin2(boolean ispin2) {
            this.ispin2 = ispin2;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getNum() {
            return num;
        }

        public void setNum(String num) {
            this.num = num;
        }

        public double getVoltage() {
            return voltage;
        }

        public void setVoltage(double voltage) {
            this.voltage = voltage;
        }

        public Equipment(ControlDevice controlDevice) {
            this.controlDevice = controlDevice;
            this.gears=controlDevice.getGears();
            this.voltage=controlDevice.getVoltage();
        }

        public Equipment() {
        }

        public ControlDevice getControlDevice() {
            return controlDevice;
        }

        public void setControlDevice(ControlDevice controlDevice) {
            this.controlDevice = controlDevice;
        }

        public double getGears() {
            return gears;
        }

        public void setGears(double gears) {
            this.gears = gears;
        }
    }

    public static class ControlDevice {

        private double gears=0;//檔位
        private boolean isOpen;
        private double InputPins1=0;//輸入引腳
        private double OutputPins2=0;//輸出引腳
        private boolean ispin1=false;
        private boolean ispin2=false;
        private String name;
        private String num;

        public String getNum() {
            return num;
        }

        public void setNum(String num) {
            this.num = num;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public boolean isIspin1() {
            return ispin1;
        }

        public void setIspin1(boolean ispin1) {
            this.ispin1 = ispin1;
        }

        public boolean isIspin2() {
            return ispin2;
        }

        public void setIspin2(boolean ispin2) {
            this.ispin2 = ispin2;
        }

        private double voltage;
        public ControlDevice(double inputPins1, double outputPins2) {
            this.isOpen = true;
            this.InputPins1 = inputPins1;
            this.OutputPins2 = outputPins2;
        }

        public boolean isOpen() {
            return isOpen;
        }

        public void setOpen(boolean open) {
            isOpen = open;
        }

        public double getVoltage() {
            if(isOpen){
            return (InputPins1-OutputPins2)*gears;
            }else {
                return 0;
            }
        }


        public void setVoltage(double voltage) {
            this.voltage = voltage;
        }

        public ControlDevice() {
            this.isOpen=true;
        }

        public double getGears() {
            return gears;
        }

        public void setGears(double gears) {
            if(gears>=0.00&&gears<=1.00){
            this.gears = gears;
            }
        }

        public void ChangeOpen() {
            if(this.isOpen){
                this.isOpen=false;
            }else {
                this.isOpen=true;
            }
        }

        public boolean getOpen() {
            return isOpen;
        }

        public double getInputPins1() {
            return InputPins1;
        }

        public void setInputPins1(double inputPins1) {
            InputPins1 = inputPins1;
        }

        public double getOutputPins2() {
            return OutputPins2;
        }

        public void setOutputPins2(double outputPins2) {
            OutputPins2 = outputPins2;
        }
    }

    public static class circuitCL {
        private ControlDevice controlDevice;
        private Equipment equipment;
        private Switch aSwitch=null;

        public circuitCL() {
        }

        public ControlDevice getControlDevice() {
            return controlDevice;
        }

        public void setControlDevice(ControlDevice controlDevice) {
            this.controlDevice = controlDevice;
        }

        public Equipment getEquipment() {
            return equipment;
        }

        public void setEquipment(Equipment equipment) {
            this.equipment = equipment;
        }

        public Switch getaSwitch() {
            return aSwitch;
        }

        public void setaSwitch(Switch aSwitch) {
            this.aSwitch = aSwitch;
        }
    }
}

對於任何不同的電器,都應該存在輸入電壓和輸出電壓的方法。因此我們應該把輸入電壓和輸出的作為父類的方法。 並且可以透過將輸入輸出電壓方法作為這個介面的方法,並由父類裝置類實現這個方法。

3.nchu-software-oop-2024-上-6:智慧家用電器系統(二)

(1)解題思路:本題將並聯電路拆分為多個串聯電路並將其儲存在一個ArryList中作為一個並聯電路,然後將總電路看作一個串聯電路,將並聯電路看作該串聯電路的一個用電器,進行操作

(2)類的設計:
類圖如下

具體類的實現程式碼如下:

 class RGlight extends equipment {
        public RGlight(String name) {
            super(name);
        }
        private double light;

        public double getLight() {
            if(getVoltage()==0){
                setLight(0);
            } else {
                setLight(180);
            }
            return light;
        }

        public void setLight(double light) {
            this.light = light;
        }
    }

     class sort {
        public sort() {
        }

        public  void bubbleSort(ArrayList<DFans> list) {
            for(int i = 0; i < list.size() - 1; ++i) {
                for(int j = 0; j < list.size() - i - 1; ++j) {
                    if (((equip)list.get(j)).getName().compareTo(((equip)list.get(j + 1)).getName()) > 0) {
                        Collections.swap(list, j, j + 1);
                    }
                }
            }

        }
    }

     class Switch extends ControlDevice {
        public Switch() {
        }

        public Switch(String name) {
            setName(name);
            setGears(0);
        }
        public void changeopen(){
            if(getGears()==0){
                setGears(1.0);
            }else if(getGears()==1.0){
                setGears(0);
            }
        }
    }

    class LXGovernor extends ControlDevice {
        public LXGovernor() {
        }
        public LXGovernor(String name) {
            super(name);
            setGears(0);
        }
    }

     class LFans extends equipment {
        public LFans(String name) {
            super(name);
            setResistence(20);
        }
        private double speed;

        public double getSpeed() {
            if(getVoltage()>=80&&getVoltage()<100){
                setSpeed(80);
            } else if (getVoltage()>=100&&getVoltage()<120) {
                setSpeed(160);
            }else if (getVoltage()>=120&&getVoltage()<140) {
                setSpeed(260);
            }else if (getVoltage()>=140) {
                setSpeed(360);
            }
            return speed;
        }

        public void setSpeed(double speed) {
            this.speed = speed;
        }
    }

    class FDGovernor extends ControlDevice {
        private double[] gears=new double[]{0.0,0.3,0.6,0.9};
        private int i=0;



        public void setGears(double[] gears) {
            this.gears = gears;
        }

        public int getI() {
            return i;
        }

        public void setI(int i) {
            this.i = i;
        }

        public FDGovernor() {
        }

        public FDGovernor(String name) {
            super(name);
            setGears(0);
        }

        public void addgears(){
            if(i<3){
                i++;
                setGears(gears[i]);
            }
        }
        public void delgears(){
            if(i>0){
                i--;
                setGears(gears[i]);
            }
        }

    }

     class equipment extends equip {
        private String name;
        private String num;
        private String pin1name;
        private String pin2name;
        private double voltage;
        private double resistence;



        public equipment(String name) {
            this.name = name;
        }
        public double getResistence() {
            return resistence;
        }

        public void setResistence(double resistence) {
            this.resistence = resistence;
        }
        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getNum() {
            return num;
        }

        public void setNum(String num) {
            this.num = num;
        }

        public String getPin1name() {
            return pin1name;
        }

        public void setPin1name(String pin1name) {
            this.pin1name = pin1name;
        }

        public String getPin2name() {
            return pin2name;
        }

        public void setPin2name(String pin2name) {
            this.pin2name = pin2name;
        }

        public double getVoltage() {
            return voltage;
        }

        public void setVoltage(double voltage) {
            this.voltage = voltage;
        }
    }

     class equip {
        private String name;
        private String num;
        public equip() {
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getNum() {
            return num;
        }

        public void setNum(String num) {
            this.num = num;
        }
    }

     class ControlDevice extends equip {
        private String name;
        private String num;
        private double gears;

        public ControlDevice() {
        }

        public ControlDevice(String name) {
            this.name = name;
            setGears(0);
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getNum() {
            return num;
        }

        public void setNum(String num) {
            this.num = num;
        }

        public double getGears() {
            return gears;
        }

        public void setGears(double gears) {
            this.gears = gears;
        }
    }

     class DFans extends equipment {
        private double speed;
        public DFans(String name) {
            super(name);
            setResistence(20.0);
        }

        public double getSpeed() {
            if(getVoltage()>=80&&getVoltage()<=150){
               setSpeed((getVoltage()-80)*((360-80)/70.0)+80);
            } else if (getVoltage()>150){
                setSpeed(360);
            } else if (getVoltage()<80) {
                setSpeed(0);
            }
            return speed;
        }

        public void setSpeed(double speed) {
            this.speed = speed;
        }
    }

     class circuitBL extends circuit {
        private ArrayList<circultCL> circultCLArrayList=new ArrayList<>();

        private double voltage;
        private double resistence;
        private  boolean istrue=true;
        private String name;
        public circuitBL() {
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public ArrayList<circultCL> getCircultCLArrayList() {
            return circultCLArrayList;
        }

        public void setCircultCLArrayList(ArrayList<circultCL> circultCLArrayList) {
            this.circultCLArrayList = circultCLArrayList;
        }

        public double getVoltage() {
            return voltage;
        }

        public void setVoltage(double voltage) {
            this.voltage = voltage;
        }

        public double getResistence() {
            double resistence=0;
            for (int i = 0; i < circultCLArrayList.size(); i++) {
                //System.out.println(circultCLArrayList.get(i).isIstrue());
                if(circultCLArrayList.get(i).isIstrue()){
                    resistence+=1.0/ circultCLArrayList.get(i).getResistence();
                }
            }
            resistence=1.0/resistence;
            return resistence;
        }

        public void setResistence(double resistence) {
            this.resistence = resistence;
        }

        public boolean isIstrue() {
            return istrue;
        }

        public void setIstrue(boolean istrue) {
            this.istrue = istrue;
        }
    }

     class BZlight extends equipment {
        public BZlight(String name) {
            super(name);
        }
        private double light;

        public double getLight() {
            if(getVoltage()>=0&&getVoltage()<=9){
                setLight(0);
            } else if(getVoltage()>9){
                setLight((getVoltage()-10)*(150/210)+50);
            }
            return light;
        }

        public void setLight(double light) {
            this.light = light;
        }
    }

     class circuit extends equip {
    }

   class circultCL extends circuit {
        private String name;
        private ArrayList<equip>equipArrayList = new ArrayList<>();
        private double voltage;
        private double resistence;
        private  boolean istrue=true;

        public circultCL() {
            this.istrue = istrue;
        }

        public circultCL(String name) {
            this.name = name;
        }

        public ArrayList<equip> getEquipArrayList() {
            return equipArrayList;
        }

        public void setEquipArrayList(ArrayList<equip> equipArrayList) {
            this.equipArrayList = equipArrayList;
        }

        public double getVoltage() {
            return voltage;
        }

        public void setVoltage(double voltage) {
            this.voltage = voltage;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public double getResistence() {
            double resistence=0;
            for (int i = 0; i < equipArrayList.size(); i++) {
                if(equipArrayList.get(i) instanceof Switch){
                    if(((Switch) equipArrayList.get(i)).getGears()==0){
                        setIstrue(false);
                        return 0;
                    }
                }
                if(istrue&&equipArrayList.get(i) instanceof equipment){
                    resistence+=((equipment) getEquipArrayList().get(i)).getResistence();
                }
            }
            if(isIstrue()){
                this.setResistence(resistence);
                return resistence;
            }else {
            this.setResistence(0);
            return 0;
            }
        }

        public void setResistence(double resistence) {
            this.resistence = resistence;
        }

        public boolean isIstrue() {
            return istrue;
        }

        public void setIstrue(boolean istrue) {
            this.istrue = istrue;
        }
    }

三、採坑心得

(1)對字串的處理方面,要從字串中提取出有效資訊並進行儲存,而在提取有效資訊方面正規表示式的格式是一個重要問題,在這三次題集中,由於正規表示式的格式錯誤,導致了輸入無效資訊等一系列錯誤
(2)在並聯電路中,我們需要考慮到電源短路的情況

例如:

Exception in thread "main" java.lang.NumberFormatException: Cannot parse null string

at java.base/java.lang.Integer.parseInt(Integer.java:624)

at java.base/java.lang.Integer.parseInt(Integer.java:778)

at Paper.sumscoreJudge(Main.java:23) at Main.main(Main.java:66)

(2)在使用ArryList.get( )時,由於未注意List的大小,導致陣列越界

例如,在PTA-4中報錯

Exception in thread "main" java.lang.NullPointerException: Cannot assign field "ques" because "question[no]" is null

at Main.main(Main.java:39)

(3)在設計子類時,經常忘記重寫父類的方法

2.(1)nchu-software-oop-2024-上-4:在最初設計本題的過程中,我對於如何輸入並儲存資料並不清楚,這是一個難點。後續我引入了hashmap來進行資料儲存

(2)nchu-software-oop-2024-上-5:對於這道題目我們只需要輸入後對相關字串進行分割後進行儲存即可,只需要注意理解題目意思即可,比如在對調檔器進行調低一擋操作

時,需要注意調檔器的最高的檔位和最低的檔位為3和0,如果未注意則會出現大面積錯誤

(3)nchu-software-oop-2024-上-6:對與這道題目而言,需要對電路進行分割,需要注意的地方在於要判斷支路中的開關是否全部閉合,因為題目中並聯電路的開關不一定全部閉合所以並聯電路中的用電器不一定都有電壓,其他注意點同nchu-software-oop-2024-上-5

3.這三次大作業的心得:
(1)理解程式設計邏輯的重要性:在編寫答題判題程式時,邏輯是關鍵。確保你完全理解題目的要求和評分標準,然後將其轉化為程式碼邏輯。這需要對程式設計和資料結構有深入的理解
(2)模組化程式設計的便利:將程式劃分為多個模組或函式可以使程式碼更易於理解和維護。每個模組負責特定的功能,如讀取題目、解析答案、評分等。
(3)異常處理的必要性:在程式設計過程中,會遇到各種意外情況,如輸入錯誤、對應資訊不存在等。使用異常處理機制可以確保程式在遇到問題時能夠優雅地處理,而不是崩潰。

四、改進建議

1.nchu-software-oop-2024-上-4:(1)可考慮使用hashmap類進行資料儲存

(2)可對正規表示式進行改進,使其能夠更好地能和其進行匹配
2.nchu-software-oop-2024-上-5:(1)在設計調檔器時應對調檔器地最高檔和最低檔進行限定
3.nchu-software-oop-2024-上-6:(1)在設計電路時應注意電路中用電器串聯的順序,同時設計一個判斷器用於判斷開關是否全部閉合
五、總結
1.透過這次作業我學到了:
(1)繼承的使用方法、注意事項及性質
(2)多型的實現途徑及多型的主要作用
(3)介面的實現方法、使用時的注意事項及多型的性質
(4)掌握Java語言中抽象類的基本概念及使用方法
(5)在這次作頁中還有一個很大的問題在於對題目意思理解不到位,導致許多預定功能沒有實現
(6)透過這幾次學習,我更加認識到設計類的重要性,否則寫到後面容易出錯

相關文章