ToB企服应用市场:ToB评测及商务社交产业平台

标题: 7-8次PTA总结 [打印本页]

作者: 前进之路    时间: 2024-6-30 21:48
标题: 7-8次PTA总结
后两次PTA总结

首先来看看第七次:

第七次相比于之前,添加了互斥开关元器件而且引入了并联互串等等接法,按照我之前的计划,作出改动不算太难,我之前的递归已经可以按照次序储存所以的元器件到一起去了,主要照旧归功于将串并联电路继承自元器件的方式十分有效,这样就可以或许将串并联电路当作元器件一起处置惩罚,再按照递归储存下来就可以了
新增长的变化:

加入互斥开关类,并在电子元件工厂构造添加创建内容,在输入的时候给不同支路互斥开关不同的状态,通电的时候再根据互斥开关的状态决定是否导通某条路即可,其他代码都没变,总体来说改动不大类图和之前基本一致
主要是第八次

第八次相比之前要求我们输出每个引脚的电压,而我之前一直是根据递归根据元器件的电阻分压的,这无疑加大了很多要求

我一直在想如何不动原来代码的根本上去实现最新的功能,刚开始想set电压,厥后发现情况实在是太多了,于是我想到了一个方法
给断开的开关,反向的二极管设置一个很大的电阻,多大呢,有1e9大,而那些接通的开关等等原本电阻为零,后面改成了一个很小的电阻,这样一来就可以遍历设置电压差的时候顺便盘算每个用电器管脚的电压,缺点是会有一点点精度问题(差一点得满分也是因为这个)
看看类图

源码:
  1. import java.util.*;
  2. import java.util.regex.Matcher;
  3. import java.util.regex.Pattern;
  4. interface CircuitComponent{
  5.     double getR();
  6.     void calculateOutputVoltage(double inputVoltage);
  7. }
  8. abstract class Circuit_Component implements CircuitComponent{
  9.     double r;
  10.     double rH_Cut;
  11.     String name;
  12.     Bank bank;
  13.     int hway;
  14.     int hfront;
  15.     double inputVoltage;
  16.     double outputVoltage;
  17.     double Voltagedifference;
  18.     double current;
  19.     double limiteCurrent;
  20.     double h1_V;
  21.     double middle;
  22.     public double getLimiteCurrent() {
  23.         return limiteCurrent;
  24.     }
  25.     public void setCurrent(double current){
  26.         this.current = current;
  27.     }
  28.     public double getCurrent(){
  29.         return current;
  30.     }
  31.     public void setHfront(int hfront) {
  32.         this.hfront = hfront;
  33.     }
  34.     public int getHfront() {
  35.         return hfront;
  36.     }
  37.     public void setVoltagedifference(double voltagedifference) {
  38.         Voltagedifference = voltagedifference;
  39.     }
  40.     public double getVoltagedifference() {
  41.         return Voltagedifference;
  42.     }
  43.     public void setInputVoltage(double inputVoltage) {
  44.         this.inputVoltage = inputVoltage;
  45.     }
  46.     public void setOutputVoltage(double outputVoltage) {
  47.         this.outputVoltage = outputVoltage;
  48.     }
  49.     public double getOutputVoltage() {
  50.         return outputVoltage;
  51.     }
  52.     public double getInputVoltage(){
  53.         return inputVoltage;
  54.     }
  55.     public Circuit_Component(String name) {
  56.         this.name=name;
  57.     }
  58.     public void regulation(String regulation) {}
  59.     public double getValue() {
  60.         return 0;
  61.     }
  62.     public void setBank(Bank bank) {
  63.         this.bank=bank;
  64.     }
  65.     public abstract void  calculateOutputVoltage(double inputVoltage);
  66.     public  void operate(double voltage) {
  67.     }
  68.     public String getName() {
  69.         return name;
  70.     }
  71.     public void setName(String name) {
  72.         this.name = name;
  73.     }
  74.     public void setTotalLux(T t){}
  75.     public double  getR() {
  76.         return this.r;
  77.     }
  78.     public void setR(double r) {
  79.         this.r=r;
  80.     }
  81.     public  int getHway(){return this.hway;}
  82.     public  void setHway(int hway){
  83.         this.hway=hway;
  84.     }
  85.     public double getrH_Cut(){
  86.         return this.rH_Cut;
  87.     }
  88.     public void setrH_Cut(double r){
  89.         this.rH_Cut=r;
  90.     }
  91.     @Override
  92.     public boolean equals(Object obj) {
  93.         if (this == obj) {
  94.             return true;
  95.         }
  96.         if (obj == null||getClass() != obj.getClass()) {
  97.             return false;
  98.         }
  99.         Circuit_Component other = (Circuit_Component) obj;
  100.         return name != null ? name.equals(other.name):other.name == null;
  101.     }
  102.     @Override
  103.     public int hashCode() {
  104.         return name != null ? name.hashCode() : 0;
  105.     }
  106.     public double getH1_V() {
  107.         return h1_V;
  108.     }
  109.     public void setH1_V(double h1_V) {
  110.         this.h1_V = h1_V;
  111.     }
  112.     public double getMiddle() {
  113.         return middle;
  114.     }
  115.     public void setMiddle(double middle) {
  116.         this.middle = middle;
  117.     }
  118. }
  119. class PowerSupply extends Circuit_Component{
  120.     public PowerSupply(String name) {
  121.         super(name);
  122.         r=0;
  123.     }
  124.     private static final int INPUT_VOLTAGE = 220;
  125.     @Override
  126.     public void calculateOutputVoltage(double inputVoltage) {
  127.         setInputVoltage(INPUT_VOLTAGE);
  128.         setOutputVoltage(INPUT_VOLTAGE);
  129.     }
  130. }
  131. class Ground extends Circuit_Component {
  132.     public Ground(String name) {
  133.         super(name);
  134.     }
  135.     @Override
  136.     public void calculateOutputVoltage(double inputVoltage) {
  137.         setInputVoltage(0);
  138.     }
  139. }
  140. class Switch extends Circuit_Component{
  141.     private boolean status=false;
  142.     public Switch(String component_Input) {
  143.         super(component_Input);
  144.         this.r=0.000000001;
  145.         this.limiteCurrent=20;
  146.     }
  147.     @Override
  148.     public void regulation(String regulation) {
  149.         this.status=!status;
  150.     }
  151.     @Override
  152.     public  double getValue(){
  153.         if (status)return 1;
  154.         else return 0;
  155.     }
  156.     @Override
  157.     public void calculateOutputVoltage(double inputVoltage) {
  158.         setInputVoltage(inputVoltage);
  159.         if(this.status){
  160.             setOutputVoltage(inputVoltage);
  161.         }
  162.         else {
  163.             setOutputVoltage(0);
  164.         }
  165.     }
  166. }
  167. class P extends Circuit_Component{
  168.     private boolean status=false;
  169.     public P(String component_Input) {
  170.         super(component_Input);
  171.         this.r=0.000000001;
  172.         this.limiteCurrent=10;
  173.     }
  174.     public void setR(){
  175.         if(this.hway==1){
  176.             this.r=0.000000001;
  177.         }else{
  178.             this.r=1e9;
  179.         }
  180.     }
  181.     @Override
  182.     public double getR(){
  183.         setR();
  184.         return this.r;
  185.     }
  186.     @Override
  187.     public void calculateOutputVoltage(double inputVoltage) {}
  188. }
  189. class H extends Circuit_Component {
  190.     private boolean status=false;
  191.     private int hway=2;
  192.     public H(String component_Input) {
  193.         super(component_Input);
  194.         this.r=0.00000001;
  195.         this.rH_Cut=1e9;
  196.         this.limiteCurrent=20;
  197.     }
  198.     public void setRH(){
  199.         if(!status){
  200.             this.r=5;
  201.         }else{
  202.             this.r=10;
  203.         }
  204.     }
  205.     public  double getValue(){
  206.         if (status)return 1;
  207.         else return 0;
  208.     }
  209.     @Override
  210.     public  int getHway(){
  211.         return  this.hway;
  212.     }
  213.     @Override
  214.     public  void setHway(int hway){
  215.         this.hway=hway;
  216.     }
  217.     public void regulation(String regulation) {
  218.         this.status=!status;
  219.     }
  220.     @Override
  221.     public double  getR() {
  222.         setRH();
  223.         if(hway==2&& status){
  224.             return 1e9;
  225.         }else if(hway==3&& !status){
  226.             return 1e9;
  227.         }
  228.         if(!status)return 5;
  229.         else return 10;
  230.     }
  231.     @Override
  232.     public void calculateOutputVoltage(double inputVoltage) {
  233.         setInputVoltage(inputVoltage);
  234.     }
  235. }
  236. abstract class Governor  extends Circuit_Component{
  237.     public Governor(String name) {
  238.         super(name);
  239.         r=0;
  240.     }
  241.     @Override
  242.     public abstract void  calculateOutputVoltage(double inputVoltage);
  243. }
  244. class F extends Governor {
  245.     private int gear = 0;
  246.     public F(String component_Input) {
  247.         super(component_Input);
  248.         this.limiteCurrent=18;
  249.     }
  250.     @Override
  251.     public double getValue() {
  252.         return gear;
  253.     }
  254.     @Override
  255.     public void calculateOutputVoltage(double inputVoltage) {
  256.         double changeVoltage = 0;
  257.         switch (gear) {
  258.             case 0:
  259.                 changeVoltage = 0;break;
  260.             case 1:
  261.                 changeVoltage = inputVoltage * 0.3;break;
  262.             case 2:
  263.                 changeVoltage = inputVoltage * 0.6;break;
  264.             case 3:
  265.                 changeVoltage = inputVoltage * 0.9;break;
  266.             default:break;
  267.         }
  268.         setOutputVoltage(changeVoltage);
  269.     }
  270.     @Override
  271.     public void regulation(String regulation) {
  272.         if ("+".equals(regulation)) {
  273.             gear++;
  274.             if(gear>=3)gear=3;
  275.         } else if ("-".equals(regulation)) {
  276.             gear--;
  277.             if(gear<=0)gear=0;
  278.         }
  279.     }
  280. }
  281. class L extends Governor{
  282.     private double smoothGear;
  283.     public L(String component_Input) {
  284.         super(component_Input);
  285.         this.smoothGear=0;
  286.         this.limiteCurrent=18;
  287.     }
  288.     @Override
  289.     public double getValue() {
  290.         return smoothGear;
  291.     }
  292.     public void setGear(double gear) {
  293.         this.smoothGear=gear;
  294.     }
  295.     @Override
  296.     public void regulation(String regulation) {
  297.         this.smoothGear=Double.valueOf(regulation);
  298.     }
  299.     @Override
  300.     public void calculateOutputVoltage(double inputVoltage) {
  301.         setOutputVoltage(inputVoltage*smoothGear);
  302.     }
  303. }
  304. abstract class ElectricalAppliances  extends Circuit_Component{
  305.     public ElectricalAppliances(String name) {
  306.         super(name);
  307.     }
  308.     int id;
  309.     @Override
  310.     public  void  calculateOutputVoltage(double inputVoltage){
  311.         setInputVoltage(inputVoltage);
  312.         setOutputVoltage(inputVoltage-getVoltagedifference());
  313.     }
  314.     public abstract void operate(double voltage);
  315. }
  316. class B extends ElectricalAppliances{
  317.     private double brightness;
  318.     public B(String name) {
  319.         super(name);
  320.         this.r=10;
  321.         this.limiteCurrent=9;
  322.     }
  323.     public void flash(double voltage) {
  324.         if (voltage < 9) {
  325.             this.brightness=0;
  326.         } else if (voltage >= 219) {
  327.             this.brightness=200;
  328.         } else {
  329.             double brightness = 50 + (voltage - 10) * ((200.0 - 50) / (220 - 10));
  330.             this.brightness=brightness;
  331.         }
  332.     }
  333.     @Override
  334.     public void operate(double voltage) {
  335.         setVoltagedifference(voltage);
  336.         flash(voltage);
  337.     }
  338.     @Override
  339.     public double getValue() {
  340.         return this.brightness;
  341.     }
  342. }
  343. class R extends ElectricalAppliances{
  344.     private double light;
  345.     public R(String component_Input) {
  346.         super(component_Input);
  347.         this.r=5;
  348.         this.limiteCurrent=5;
  349.     }
  350.     public void flash(double voltage) {
  351.         if (voltage>0.0001) this.light=180;
  352.         else this.light=0;
  353.     }
  354.     @Override
  355.     public void operate(double voltage) {
  356.         setVoltagedifference(voltage);
  357.         flash(voltage);
  358.     }
  359.     @Override
  360.     public double getValue() {
  361.         return this.light;
  362.     }
  363. }
  364. class D extends ElectricalAppliances{
  365.     private double speed;
  366.     public D(String component_Input) {
  367.         super(component_Input);
  368.         this.r=20;
  369.         this.limiteCurrent=12;
  370.     }
  371.     public  void calculateSpeed(double voltage) {
  372.         double speed = 0;
  373.         if (voltage < 79) {
  374.             speed = 0;
  375.         } else if (voltage >= 149) {
  376.             speed = 360;
  377.         } else {
  378.             speed = 80 + (voltage - 80) * ((360 - 80) / (150 - 80));
  379.         }
  380.         this.speed=speed;
  381.     }
  382.     @Override
  383.     public void operate(double voltage) {
  384.         setVoltagedifference(voltage);
  385.         calculateSpeed(voltage);
  386.     }
  387.     @Override
  388.     public double getValue() {
  389.         return this.speed;
  390.     }
  391. }
  392. class A extends ElectricalAppliances{
  393.     private double speed;
  394.     public A(String name) {
  395.         super(name);
  396.         this.r=20;
  397.         this.limiteCurrent=14;
  398.     }
  399.     public void calculateSpeed(double voltage) {
  400.         if (voltage >= 80 && voltage < 100) {
  401.             this.speed = 80;
  402.         } else if (voltage >= 100 && voltage < 120) {
  403.             this.speed = 160;
  404.         } else if (voltage >= 120 && voltage < 140) {
  405.             this.speed = 260;
  406.         } else if (voltage >= 140) {
  407.             this.speed = 360;
  408.         }
  409.     }
  410.     @Override
  411.     public void operate(double voltage) {
  412.         setVoltagedifference(voltage);
  413.         calculateSpeed(voltage);
  414.     }
  415.     @Override
  416.     public double getValue(){
  417.         return this.speed;
  418.     }
  419. }
  420. class S extends ElectricalAppliances{
  421.     private double curtainPosition=1.0;
  422.     private double totalLux=0;
  423.     public  Bank bank;
  424.     public S(String name) {
  425.         super(name);
  426.         this.r = 15;
  427.         this.limiteCurrent=12;
  428.     }
  429.     public void setBank(Bank bank){
  430.         this.bank=bank;
  431.     }
  432.     @Override
  433.     public void setTotalLux(T t) {
  434.         for(Circuit_Component component:t.getConcatenationList()){
  435.             if(component.getName().startsWith("R")||component.getName().startsWith("B")){
  436.                 totalLux+=component.getValue();
  437.             }else if(component.getName().startsWith("M")){
  438.                 for(T t1:bank.lookforM(component.getName()).getMList()){
  439.                     setTotalLux(t1);
  440.                 }
  441.             } else if (component.getName().startsWith("T")) {
  442.                 setTotalLux((T)component);
  443.             }
  444.         }
  445.     }
  446.     @Override
  447.     public void operate(double voltage) {
  448.         setVoltagedifference(voltage);
  449.         if(voltage<0.0001){
  450.             curtainPosition = 0;
  451.         }else if (voltage < 50&&voltage>0.0001) {
  452.             curtainPosition = 1.0;
  453.         }else {
  454.             if (totalLux < 50) {
  455.                 curtainPosition = 1.0;
  456.             } else if (totalLux < 100) {
  457.                 curtainPosition = 0.8;
  458.             } else if (totalLux < 200) {
  459.                 curtainPosition = 0.6;
  460.             } else if (totalLux < 300) {
  461.                 curtainPosition = 0.4;
  462.             } else if (totalLux < 400) {
  463.                 curtainPosition = 0.2;
  464.             } else {
  465.                 curtainPosition = 0.0;
  466.             }
  467.         }
  468.     }
  469.     @Override
  470.     public double getValue(){
  471.         return this.curtainPosition;
  472.     }
  473. }
  474. class T extends Circuit_Component{
  475.     private String name;
  476.     private List<Circuit_Component> concatenationList;
  477.     private Bank bank;
  478.     private double Hstatus = 0;
  479.     public T(Bank bank) {
  480.         super("null");
  481.         this.bank = bank;
  482.         concatenationList=new ArrayList<>();
  483.     }
  484.     public List<Circuit_Component> getConcatenationList() {
  485.         return concatenationList;
  486.     }
  487.     @Override
  488.     public void calculateOutputVoltage(double inputVoltage) {}
  489.     public String getName() {
  490.         return name;
  491.     }
  492.     public double getR(){
  493.         double r = 0;
  494.         for(Circuit_Component circuitComponent:concatenationList){
  495.             if((this.getHstatus()==2&&circuitComponent.getName().startsWith("R")&&circuitComponent.getValue()==1)||(this.getHstatus()==3&&circuitComponent.getName().startsWith("R")&&circuitComponent.getValue()==0)){
  496.                 r+=1e9;
  497.             }else{
  498.                 r+=circuitComponent.getR();
  499.             }
  500.         }
  501.         return r;
  502.     }
  503.     public double getHstatus(){
  504.         return Hstatus;
  505.     }
  506.     public void dataInput(String input) {
  507.         String regex = "[a-zA-Z]+\\d+|VCC|GND";;
  508.         Pattern pattern = Pattern.compile(regex);
  509.         Matcher matcher = pattern.matcher(input);
  510.         HashSet<String> set = new HashSet<>();
  511.         boolean ifBegin=true;
  512.         while (matcher.find()) {
  513.             String match = matcher.group();
  514.             if( !set.contains(match) ) {
  515.                 if (match.startsWith("T")) {
  516.                     if (ifBegin) {
  517.                         this.name = match;
  518.                         ifBegin = false;
  519.                     } else {
  520.                         concatenationList.add(bank.lookforT(match));
  521.                         set.add(match);
  522.                     }
  523.                 } else {
  524.                     if (match.startsWith("M")) {
  525.                         concatenationList.add(bank.lookforM(match));
  526.                         set.add(match);
  527.                     } else {
  528.                         concatenationList.add(ComponentItemFactory.createComponent(match));
  529.                         set.add(match);
  530.                     }
  531.                 }
  532.             }
  533.         }
  534.         boolean firstMatchProcessed = false;
  535.         String regexH = "H\\d+-\\d+";
  536.         Pattern patternH = Pattern.compile(regexH);
  537.         Matcher matcherH = patternH.matcher(input);
  538.         HashSet<String> setH = new HashSet<>();
  539.         while (matcherH.find()) {
  540.             String match = matcherH.group();
  541.             String[] parts = match.split("-");
  542.             if(parts[1].equals("2")){
  543.                 bank.looker(parts[0],this).setHway(2);
  544.                 this.Hstatus=2;
  545.             }
  546.             else if(parts[1].equals("3")){
  547.                 bank.looker(parts[0],this).setHway(3);
  548.                 this.Hstatus=3;
  549.             }
  550.             if(!firstMatchProcessed){
  551.                 if(parts[1].equals("1")){
  552.                     bank.looker(parts[0],this).setHfront(1);
  553.                 }
  554.                 else if(parts[1].equals("2")||parts[1].equals("3")){
  555.                     bank.looker(parts[0],this).setHfront(2);
  556.                 }
  557.                 firstMatchProcessed=true;
  558.             }
  559.         }
  560.         String regexAll = "[A-GI-Z]\\d+-\\d+";
  561.         Pattern patternAll = Pattern.compile(regexAll);
  562.         Matcher matcherAll = patternAll.matcher(input);
  563.         HashSet<String> setAll = new HashSet<>();
  564.         while (matcherAll.find()) {
  565.             if(!setAll.contains(matcherAll.group().split("-")[0])) {
  566.                 String match = matcherAll.group();
  567.                 String[] parts = match.split("-");
  568.                 if(parts[1].equals("1")){
  569.                     bank.looker(parts[0],this).setHway(1);
  570.                     setAll.add(parts[0]);
  571.                 }
  572.                 else if(parts[1].equals("2")){
  573.                     bank.looker(parts[0],this).setHway(2);
  574.                     setAll.add(parts[0]);
  575.                 }
  576.             }
  577.         }
  578.     }
  579. }
  580. class M extends Circuit_Component{
  581.     private ArrayList<T> mList= new ArrayList<T>();
  582.     private Bank bank;
  583.     public M(Bank bank) {
  584.         super("null");
  585.         this.bank = bank;
  586.     }
  587.     public ArrayList<T> getMList(){
  588.         return this.mList;
  589.     }
  590.     @Override
  591.     public void calculateOutputVoltage(double inputVoltage) {}
  592.     public void setData(String input){
  593.         String regex = "[a-zA-Z]\\d+";
  594.         Pattern pattern = Pattern.compile(regex);
  595.         Matcher matcher = pattern.matcher(input);
  596.         //   HashSet<String> set = new HashSet<>();
  597.         while (matcher.find()) {
  598.             String match = matcher.group();
  599.             if(match.startsWith("M")){
  600.                 this.name=match;
  601.             }else {
  602.                 mList.add(bank.lookforT(match));
  603.                 //  set.add(match);
  604.             }
  605.         }
  606.     }
  607.     @Override
  608.     public double getR() {
  609.         double r = 0;
  610.         boolean ifCount=true;
  611.         for (T t : mList) {
  612.             ifCount=true;
  613.             if(ifCount) {
  614.                 double resistance = t.getR();
  615.                 r += 1 / resistance;
  616.             }
  617.         }
  618.         return 1 / r;
  619.     }
  620. }
  621. class Bank {
  622.     private List<T> tList;
  623.     private List<M> mList;
  624.     private Operate operate;
  625.     public Bank() {
  626.         tList=new ArrayList<>();
  627.         mList=new ArrayList<>();
  628.         operate=new Operate(this);
  629.     }
  630.     public List<T> getTList(){
  631.         return this.tList;
  632.     }
  633.     public void setData(Scanner sc,Operate operate){
  634.         String input= sc.nextLine();
  635.         while (!input.startsWith("end")){
  636.             if (input.startsWith("#T")||input.startsWith("#M")){
  637.                 if(input.startsWith("#T")) {
  638.                     T t = new T(this);
  639.                     t.dataInput(input);
  640.                     tList.add(t);
  641.                 } else if (input.startsWith("#M")) {
  642.                     M m=new M(this);
  643.                     m.setData(input);
  644.                     mList.add(m);
  645.                 }
  646.             }else{
  647.                 operate.operate(input);
  648.             }
  649.             input= sc.nextLine();
  650.         }
  651.     }
  652.     public Circuit_Component looker(String name, T t){
  653.         for(Circuit_Component circuitComponent: t.getConcatenationList()){
  654.             String names= circuitComponent.getName();
  655.             if(names.startsWith("M")){
  656.                 for(T t1:lookforM(names).getMList()){
  657.                     if (looker(name,t1)==null)continue;
  658.                     else return looker(name,t1);
  659.                 }
  660.             }else if(names.startsWith("T")){
  661.                 if (looker(name,(T)circuitComponent)==null)continue;
  662.                 else return looker(name,(T)circuitComponent);
  663.             }else if(name.equals(names)){
  664.                 return circuitComponent;
  665.             }
  666.         }
  667.         return null;
  668.     }
  669.     public void operatorH(String name, T t){
  670.         for(Circuit_Component circuitComponent: t.getConcatenationList()){
  671.             String names= circuitComponent.getName();
  672.             if(names.startsWith("M")){
  673.                 for(T t1:lookforM(names).getMList()){
  674.                     operatorH(name,t1);
  675.                 }
  676.             }else if(names.startsWith("T")){
  677.                 operatorH(name,(T)circuitComponent);
  678.             }else if(name.equals(names)){
  679.                 circuitComponent.regulation("");
  680.             }
  681.         }
  682.     }
  683.     public List<Circuit_Component> sortArrayOutput(T t, List<Circuit_Component> list){
  684.         for(Circuit_Component circuitComponent:t.getConcatenationList()){
  685.             String name=circuitComponent.getName();
  686.             if(!name.equals("VCC")&&!name.equals("GND")){
  687.                 if (name.startsWith("M")){
  688.                     for(T t1:lookforM(name).getMList()){
  689.                         sortArrayOutput(t1,list);
  690.                     }
  691.                 }else if(name.startsWith("T")){
  692.                     sortArrayOutput((T)circuitComponent,list);
  693.                 }else{
  694.                     list.add(circuitComponent);
  695.                 }
  696.             }
  697.         }
  698.         return list;
  699.     }
  700.     public T lookforT(String input){
  701.         for(T t:tList){
  702.             if(t.getName().equals(input)){
  703.                 return t;
  704.             }
  705.         }
  706.         return null;
  707.     }
  708.     public M lookforM(String input){
  709.         for(M m:mList){
  710.             if(m.getName().equals(input)){
  711.                 return m;
  712.             }
  713.         }
  714.         return null;
  715.     }
  716. }
  717. class Operate{
  718.     private Bank bank;
  719.     public Operate(Bank bank){
  720.         this.bank=bank;
  721.     }
  722.     public  void operate(String input) {
  723.         int index = input.indexOf('#');
  724.         if(input.startsWith("#K")){
  725.             if(bank.looker(input.replace("#", ""),bank.getTList().get(bank.getTList().size()-1))!=null){
  726.                 bank.looker(input.replace("#", ""),bank.getTList().get(bank.getTList().size()-1)).regulation("");
  727.             }
  728.         } else if (input.startsWith("#H")) {
  729.             bank.operatorH(input.replace("#", ""),bank.getTList().get(bank.getTList().size()-1));
  730.         } else if (input.startsWith("#L")) {
  731.             int startIndex = input.indexOf("#") + 1;
  732.             int colonIndex = input.indexOf(":");
  733.             String l1 = input.substring(startIndex, colonIndex);
  734.             String value = input.substring(colonIndex + 1);
  735.             bank.looker(l1,bank.getTList().get(bank.getTList().size()-1)).regulation(value);
  736.         } else if (input.startsWith("#F")) {
  737.             Pattern pattern = Pattern.compile("#(F\\d+)([\\-+])");
  738.             Matcher matcher = pattern.matcher(input);
  739.             if (matcher.find()) {
  740.                 String fNumber = matcher.group(1);
  741.                 String operators = matcher.group(2);
  742.                 bank.looker(fNumber,bank.getTList().get(bank.getTList().size()-1)).regulation(operators);
  743.             }
  744.         }
  745.     }
  746. }
  747. class ComponentComparator implements Comparator<Circuit_Component> {
  748.     List<String> order = Arrays.asList("K", "F", "L", "B", "R", "D", "A", "H", "S","P");
  749.     @Override
  750.     public int compare(Circuit_Component o1, Circuit_Component o2) {
  751.         String name1 = o1.getName();
  752.         String name2 = o2.getName();
  753.         String prefix1 = name1.substring(0, 1);
  754.         String prefix2 = name2.substring(0, 1);
  755.         int index1 = order.indexOf(prefix1);
  756.         int index2 = order.indexOf(prefix2);
  757.         if (index1 != index2) {
  758.             return Integer.compare(index1, index2);
  759.         } else {
  760.             String number1 = name1.substring(1);
  761.             String number2 = name2.substring(1);
  762.             return number1.compareTo(number2);
  763.         }
  764.     }
  765. }
  766. class ComponentVoltage {
  767.     public ComponentVoltage() {
  768.     }
  769. }
  770. class ComponentVoltage2 extends ComponentVoltage {
  771.     private double voltagePin1;
  772.     private double voltagePin2;
  773.     public ComponentVoltage2(double voltagePin1, double voltagePin2) {
  774.         super();
  775.         this.voltagePin1 = voltagePin1;
  776.         this.voltagePin2 = voltagePin2;
  777.     }
  778.     public double getVoltagePin1() {
  779.         return voltagePin1;
  780.     }
  781.     public double getVoltagePin2() {
  782.         return voltagePin2;
  783.     }
  784.     @Override
  785.     public String toString() {
  786.         return "Pin1: " + voltagePin1 + ", Pin2: " + voltagePin2;
  787.     }
  788. }
  789. class ComponentVoltage3 extends ComponentVoltage {
  790.     private double voltagePin1;
  791.     private double voltagePin2;
  792.     private double voltagePin3;
  793.     public ComponentVoltage3(double voltagePin1, double voltagePin2,double voltagePin3) {
  794.         super();
  795.         this.voltagePin1 = voltagePin1;
  796.         this.voltagePin2 = voltagePin2;
  797.         this.voltagePin3 = voltagePin3;
  798.     }
  799.     public double getVoltagePin1() {
  800.         return voltagePin1;
  801.     }
  802.     public double getVoltagePin2() {
  803.         return voltagePin2;
  804.     }
  805.     public double getVoltagePin3() {
  806.         return voltagePin3;
  807.     }
  808.     @Override
  809.     public String toString() {
  810.         return "Pin1: " + voltagePin1 + ", Pin2: " + voltagePin2;
  811.     }
  812. }
  813. class HomeElectricalSystem {
  814.     private static HomeElectricalSystem instance;
  815.     private Bank bank;
  816.     private Operate operate;
  817.     private  List<Circuit_Component> list;
  818.     private double volatilebefore=220;
  819.     private double middle=0;
  820.     private double S_V;
  821.     private T tLast;
  822.     private double h1_V=1;
  823.     Map<Circuit_Component, ComponentVoltage> voltageMap = new HashMap<>();
  824.     private HomeElectricalSystem() {
  825.         this.bank=new Bank();
  826.         this.operate=new Operate(bank);
  827.         this.list=new ArrayList<>();
  828.     }
  829.     public static synchronized HomeElectricalSystem getInstance(){
  830.         if(instance==null) {
  831.             instance=new HomeElectricalSystem();
  832.         }
  833.         return instance;
  834.     }
  835.     public void setRAll(T t) {
  836.         for (Circuit_Component circuitComponent : t.getConcatenationList()) {
  837.             String name = circuitComponent.getName();
  838.             if (name.startsWith("K")) {
  839.                 if (circuitComponent.getValue() == 0) {
  840.                     circuitComponent.setR(1e9);
  841.                 }
  842.             } else if (name.startsWith("H")) {
  843.                 if (circuitComponent.getValue() == 0 && circuitComponent.getHway() == 3) {
  844.                 }
  845.                 if (circuitComponent.getValue() == 1 && circuitComponent.getHway() == 2) {
  846.                     break;
  847.                 }
  848.             } else if (name.startsWith("M")) {
  849.                 for (T t2 : bank.lookforM(name).getMList()) {
  850.                     setRAll(t2);
  851.                 }
  852.             } else if (name.startsWith("T")) {
  853.                 setRAll((T)circuitComponent);
  854.             }
  855.         }
  856.     }
  857.     public void operateR(T t) {
  858.         for (Circuit_Component circuitComponent : t.getConcatenationList()) {
  859.             String name = circuitComponent.getName();
  860.             if (name.startsWith("S")) {
  861.                 circuitComponent.setTotalLux(tLast);
  862.                 circuitComponent.operate(circuitComponent.getVoltagedifference());
  863.             } else if (name.startsWith("M")) {
  864.                 for (T t2 : bank.lookforM(name).getMList()) {
  865.                     operateR(t2);
  866.                 }
  867.             } else if (name.startsWith("T")) {
  868.                 operateR((T)circuitComponent);
  869.             }
  870.         }
  871.     }
  872.     public Circuit_Component getComponentByName(String desiredName) {
  873.         for (Circuit_Component component : voltageMap.keySet()) {
  874.             if (component.getName().equals(desiredName)) {
  875.                 return component;
  876.             }
  877.         }
  878.         return null;
  879.     }
  880.     public boolean setElectric(double V,T t,boolean ifOperate,double inputVoltage,double output_Voltage, Map<Circuit_Component, ComponentVoltage> voltageMap){
  881.         boolean ifCount=true;
  882.         if (ifCount&&ifOperate) {
  883.             double currentVoltage = inputVoltage;
  884.             for (Circuit_Component circuitComponent : t.getConcatenationList()) {
  885.                 if(circuitComponent.getName().startsWith("P11")){
  886.                     int a = 1;
  887.                 }
  888.                 String name = circuitComponent.getName();
  889.                 double tR=t.getR();
  890.                 double circuitR= circuitComponent.getR();
  891.                 double componentVoltageDrop = 0;
  892.                 if(circuitR>10000000){
  893.                     componentVoltageDrop = currentVoltage-output_Voltage;
  894.                 }else{
  895.                     componentVoltageDrop = circuitR * V / t.getR();
  896.                 }
  897.                 if(!circuitComponent.getName().startsWith("H")){
  898.                         circuitComponent.setCurrent(V/t.getR());
  899.                 }
  900.                 double outputVoltage = currentVoltage - componentVoltageDrop;
  901.                 if (name.startsWith("M")) {
  902.                     for (T t1 : bank.lookforM(name).getMList()) {
  903.                         double Vs=bank.lookforM(name).getR()*V/t.getR();
  904.                         setElectric(Vs, t1,true,currentVoltage,outputVoltage, voltageMap);
  905.                     }
  906.                 } else if(name.startsWith("T")){
  907.                     double Vs=bank.lookforT(name).getR()*V/t.getR();
  908.                     setElectric(Vs, (T)circuitComponent,true,currentVoltage,outputVoltage, voltageMap);
  909.                 }else {
  910.                     if(circuitComponent.getName().startsWith("S")){
  911.                         circuitComponent.setBank(bank);
  912.                         circuitComponent.setVoltagedifference(circuitComponent.getR()*V/t.getR());
  913.                     }else{
  914.                         circuitComponent.operate(circuitComponent.getR()*V/t.getR());
  915.                     }
  916.                 }
  917.                 if(!circuitComponent.getName().startsWith("L")&&!circuitComponent.getName().startsWith("F")){
  918.                     if(circuitComponent.getName().startsWith("H")){
  919.                         if(circuitComponent.getHfront()==1){
  920.                             if(voltageMap.containsKey(circuitComponent)){
  921.                                 circuitComponent=getComponentByName(circuitComponent.getName());
  922.                             }
  923.                             if(t.getHstatus()==2){
  924.                                 if(circuitComponent.getValue()==0){
  925.                                     circuitComponent.setCurrent(V/t.getR());
  926.                                 }
  927.                                 voltageMap.put(circuitComponent, new ComponentVoltage3(currentVoltage+0.00001, outputVoltage+0.00001,circuitComponent.getMiddle()));
  928.                                 circuitComponent.setMiddle(outputVoltage+0.00001);
  929.                             }else if(t.getHstatus()==3){
  930.                                 if(circuitComponent.getValue()==1){
  931.                                     circuitComponent.setCurrent(V/t.getR());
  932.                                 }
  933.                                 voltageMap.put(circuitComponent, new ComponentVoltage3(currentVoltage+0.00001,circuitComponent.getMiddle(), outputVoltage+0.00001));
  934.                                 circuitComponent.setMiddle(outputVoltage+0.00001);
  935.                             }
  936.                         }else{
  937.                             if(voltageMap.containsKey(circuitComponent)){
  938.                                 circuitComponent=getComponentByName(circuitComponent.getName());
  939.                             }
  940.                             if(t.getHstatus()==2){
  941.                                 if(circuitComponent.getValue()==0){
  942.                                     circuitComponent.setCurrent(V/t.getR());
  943.                                 }
  944.                                 if (outputVoltage<0.00001){
  945.                                     voltageMap.put(circuitComponent, new ComponentVoltage3(circuitComponent.getH1_V(),currentVoltage+0.00001, circuitComponent.getMiddle()));
  946.                                     circuitComponent.setMiddle(currentVoltage+0.00001);
  947.                                 }else{
  948.                                     voltageMap.put(circuitComponent, new ComponentVoltage3(outputVoltage+0.00001,currentVoltage+0.00001, circuitComponent.getMiddle()));
  949.                                     circuitComponent.setMiddle(currentVoltage+0.00001);
  950.                                     circuitComponent.setH1_V(outputVoltage+0.00001);
  951.                                 }
  952.                             }else if(t.getHstatus()==3){
  953.                                 if(circuitComponent.getValue()==1){
  954.                                     circuitComponent.setCurrent(V/t.getR());
  955.                                 }
  956.                                 if(outputVoltage<0.00001){
  957.                                     voltageMap.put(circuitComponent, new ComponentVoltage3(circuitComponent.getH1_V(),circuitComponent.getMiddle(),currentVoltage+0.00001));
  958.                                     circuitComponent.setMiddle(currentVoltage+0.00001);
  959.                                 }else{
  960.                                     voltageMap.put(circuitComponent, new ComponentVoltage3(outputVoltage+0.00001,circuitComponent.getMiddle(),currentVoltage+0.00001));
  961.                                     circuitComponent.setMiddle(currentVoltage+0.00001);
  962.                                     circuitComponent.setH1_V(outputVoltage+0.00001);
  963.                                 }
  964.                             }
  965.                         }
  966.                     }else{
  967.                         if(circuitComponent.getHway()==1){
  968.                             voltageMap.put(circuitComponent, new ComponentVoltage2(currentVoltage+0.00001, outputVoltage+0.00001));
  969.                         }else{
  970.                             voltageMap.put(circuitComponent, new ComponentVoltage2(outputVoltage+0.00001, currentVoltage+0.00001));
  971.                         }
  972.                     }
  973.                 }
  974.                 currentVoltage = outputVoltage;
  975.             }
  976.         }
  977.         return ifCount;
  978.     }
  979.     public void setPin_V(T t){
  980.         for(Circuit_Component circuitComponent: t.getConcatenationList()){
  981.             String name = circuitComponent.getName();
  982.             if(name.startsWith("K")){
  983.                 if(circuitComponent.getValue()==0){
  984.                     circuitComponent.setInputVoltage(t.getInputVoltage());
  985.                     circuitComponent.setOutputVoltage(t.getOutputVoltage());
  986.                 }
  987.             }
  988.         }
  989.     }
  990.     public void showOut(List<Circuit_Component> list){
  991.         List<Circuit_Component> lists=new ArrayList<>();
  992.         if(tLast.getR()<0.001){
  993.             System.out.println("short circuit error");
  994.         }else{
  995.             for(Circuit_Component components:list){
  996.                 ComponentVoltage2 componentVoltage = null;
  997.                 ComponentVoltage3 componentVoltageH = null;
  998.                 if(!components.getName().startsWith("H")){
  999.                     componentVoltage = (ComponentVoltage2) voltageMap.get(components);
  1000.                 }else{
  1001.                     componentVoltageH = (ComponentVoltage3) voltageMap.get(components);
  1002.                 }
  1003.                 if(components.getName().startsWith("K")&&components.getValue()==1) {
  1004.                     if(components.getCurrent()>components.getLimiteCurrent()){
  1005.                         System.out.println("@"+components.getName()+":closed "+(int)componentVoltage.getVoltagePin1()+"-"+(int)componentVoltage.getVoltagePin2()+" exceeding current limit error");
  1006.                     }else{
  1007.                         System.out.println("@"+components.getName()+":closed "+(int)componentVoltage.getVoltagePin1()+"-"+(int)componentVoltage.getVoltagePin2());
  1008.                     }
  1009.                 }else if(components.getName().startsWith("K")&&components.getValue()==0) {
  1010.                     if(components.getCurrent()>components.getLimiteCurrent()){
  1011.                         System.out.println("@"+components.getName()+":turned on "+(int)componentVoltage.getVoltagePin1()+"-"+(int)componentVoltage.getVoltagePin2()+" exceeding current limit error");
  1012.                     }else{
  1013.                         System.out.println("@"+components.getName()+":turned on "+(int)componentVoltage.getVoltagePin1()+"-"+(int)componentVoltage.getVoltagePin2());
  1014.                     }
  1015.                 }else if(components.getName().startsWith("F")){
  1016.                     if(components.getCurrent()>components.getLimiteCurrent()){
  1017.                         System.out.println("@"+components.getName()+":"+(int)Math.round(components.getValue())+" "+(int)componentVoltage.getVoltagePin1()+"-"+(int)componentVoltage.getVoltagePin2()+" exceeding current limit error");
  1018.                     }else{
  1019.                         System.out.println("@"+components.getName()+":"+(int)Math.round(components.getValue())+" "+(int)componentVoltage.getVoltagePin1()+"-"+(int)componentVoltage.getVoltagePin2());
  1020.                     }
  1021.                 }else if(components.getName().startsWith("L")){
  1022.                     if(components.getCurrent()>components.getLimiteCurrent()){
  1023.                         System.out.println("@"+components.getName()+":"+ String.format("%.2f",components.getValue())+" "+(int)componentVoltage.getVoltagePin1()+"-"+(int)componentVoltage.getVoltagePin2()+" exceeding current limit error");
  1024.                     }else{
  1025.                         System.out.println("@"+components.getName()+":"+ String.format("%.2f",components.getValue())+" "+(int)componentVoltage.getVoltagePin1()+"-"+(int)componentVoltage.getVoltagePin2());
  1026.                     }
  1027.                 }else if(components.getName().startsWith("H")&&components.getValue()==1) {
  1028.                     if(!ifExitamongList(lists, components.getName())) {
  1029.                         if(components.getCurrent()>components.getLimiteCurrent()){
  1030.                             System.out.println("@" + components.getName() + ":turned on "+(int)componentVoltageH.getVoltagePin1()+"-"+(int)componentVoltageH.getVoltagePin2()+"-"+(int)componentVoltageH.getVoltagePin3()+" exceeding current limit error");
  1031.                         }else{
  1032.                             System.out.println("@" + components.getName() + ":turned on "+(int)componentVoltageH.getVoltagePin1()+"-"+(int)componentVoltageH.getVoltagePin2()+"-"+(int)componentVoltageH.getVoltagePin3());
  1033.                         }
  1034.                     }
  1035.                 }else if(components.getName().startsWith("H")&&components.getValue()==0) {
  1036.                     if(!ifExitamongList(lists, components.getName())) {
  1037.                         if(components.getCurrent()>components.getLimiteCurrent()){
  1038.                             System.out.println("@" + components.getName() + ":closed "+(int)componentVoltageH.getVoltagePin1()+"-"+(int)componentVoltageH.getVoltagePin2()+"-"+(int)componentVoltageH.getVoltagePin3()+" exceeding current limit error");
  1039.                         }else{
  1040.                             System.out.println("@" + components.getName() + ":closed "+(int)componentVoltageH.getVoltagePin1()+"-"+(int)componentVoltageH.getVoltagePin2()+"-"+(int)componentVoltageH.getVoltagePin3());
  1041.                         }
  1042.                     }
  1043.                 }else if(components.getName().startsWith("S")) {
  1044.                     if(components.getCurrent()>components.getLimiteCurrent()){
  1045.                         System.out.println("@" + components.getName() +":"+(int)(components.getValue()*100)+"%"+" "+(int)componentVoltage.getVoltagePin1()+"-"+(int)componentVoltage.getVoltagePin2()+" exceeding current limit error");
  1046.                     }else{
  1047.                         System.out.println("@" + components.getName() +":"+(int)(components.getValue()*100)+"%"+" "+(int)componentVoltage.getVoltagePin1()+"-"+(int)componentVoltage.getVoltagePin2());
  1048.                     }
  1049.                 }else  if(components.getName().startsWith("P")) {
  1050.                     if(((int)componentVoltage.getVoltagePin1()==0&&(int)componentVoltage.getVoltagePin2()==0)||((int)componentVoltage.getVoltagePin2()-(int)componentVoltage.getVoltagePin1()!=0)){
  1051.                         if(components.getHway()==2){
  1052.                             if(components.getCurrent()>components.getLimiteCurrent()){
  1053.                                 System.out.println("@" + components.getName() +":"+"cutoff"+" "+(int)componentVoltage.getVoltagePin1()+"-"+(int)componentVoltage.getVoltagePin2()+" exceeding current limit error");
  1054.                             }else{
  1055.                                 System.out.println("@" + components.getName() +":"+"cutoff"+" "+(int)componentVoltage.getVoltagePin1()+"-"+(int)componentVoltage.getVoltagePin2());
  1056.                             }
  1057.                         }else{
  1058.                             if(components.getCurrent()>components.getLimiteCurrent()){
  1059.                                 System.out.println("@" + components.getName() +":"+"conduction"+" "+(int)componentVoltage.getVoltagePin1()+"-"+(int)componentVoltage.getVoltagePin2()+" exceeding current limit error");
  1060.                             }else{
  1061.                                 System.out.println("@" + components.getName() +":"+"conduction"+" "+(int)componentVoltage.getVoltagePin1()+"-"+(int)componentVoltage.getVoltagePin2());
  1062.                             }
  1063.                         }
  1064.                     }else if((int)componentVoltage.getVoltagePin1()==(int)componentVoltage.getVoltagePin2()){
  1065.                         if(components.getCurrent()>components.getLimiteCurrent()){
  1066.                             System.out.println("@" + components.getName() +":"+"conduction"+" "+(int)componentVoltage.getVoltagePin1()+"-"+(int)componentVoltage.getVoltagePin2()+" exceeding current limit error");
  1067.                         }else{
  1068.                             System.out.println("@" + components.getName() +":"+"conduction"+" "+(int)componentVoltage.getVoltagePin1()+"-"+(int)componentVoltage.getVoltagePin2());
  1069.                         }
  1070.                     }
  1071.                 }else if(components.getName().startsWith("B")){
  1072.                     if (components.getCurrent() > components.getLimiteCurrent()) {
  1073.                         System.out.println("@" + components.getName() + ":" + (int) components.getValue() + " " + (int) componentVoltage.getVoltagePin1() + "-" + (int) componentVoltage.getVoltagePin2() + " exceeding current limit error");
  1074.                     } else {
  1075.                         System.out.println("@" + components.getName() + ":" + (int)  components.getValue() + " " + (int) componentVoltage.getVoltagePin1() + "-" + (int) componentVoltage.getVoltagePin2());
  1076.                     }
  1077.                 }else if(components.getName().startsWith("D")){
  1078.                     if (components.getCurrent() > components.getLimiteCurrent()) {
  1079.                         System.out.println("@" + components.getName() + ":" + (int) Math.round(components.getValue()-0.1) + " " + (int) componentVoltage.getVoltagePin1() + "-" + (int) componentVoltage.getVoltagePin2() + " exceeding current limit error");
  1080.                     } else {
  1081.                         System.out.println("@" + components.getName() + ":" + (int) Math.round(components.getValue()-0.1) + " " + (int) componentVoltage.getVoltagePin1() + "-" + (int) componentVoltage.getVoltagePin2());
  1082.                     }
  1083.                 }else{
  1084.                     if (components.getCurrent() > components.getLimiteCurrent()) {
  1085.                         System.out.println("@" + components.getName() + ":" + (int) Math.round(components.getValue()) + " " + (int) componentVoltage.getVoltagePin1() + "-" + (int) componentVoltage.getVoltagePin2() + " exceeding current limit error");
  1086.                     } else {
  1087.                         System.out.println("@" + components.getName() + ":" + (int)Math.round(components.getValue()) + " " + (int) componentVoltage.getVoltagePin1() + "-" + (int) componentVoltage.getVoltagePin2());
  1088.                     }
  1089.                 }
  1090.                 lists.add(components);
  1091.             }
  1092.         }
  1093.     }
  1094.     public boolean ifExitamongList(List<Circuit_Component> list,String name){
  1095.         for(Circuit_Component components:list){
  1096.             if(components.getName().equals(name))return true;
  1097.         }
  1098.         return false;
  1099.     }
  1100.     public void TakeIn(Scanner scanner) {
  1101.         bank.setData(scanner,operate);
  1102.         double Vinput=220;
  1103.         if(bank.getTList().get(bank.getTList().size()-1).getConcatenationList().get(1).getName().startsWith("F")||bank.getTList().get(bank.getTList().size()-1).getConcatenationList().get(1).getName().startsWith("L")){
  1104.             bank.getTList().get(bank.getTList().size()-1).getConcatenationList().get(1).calculateOutputVoltage(220);
  1105.             Vinput=bank.getTList().get(bank.getTList().size()-1).getConcatenationList().get(1).getOutputVoltage();
  1106.         }
  1107.         bank.getTList().get(bank.getTList().size()-1).setInputVoltage(220);
  1108.         setRAll(bank.getTList().get(bank.getTList().size()-1));
  1109.         if (Vinput!=0){
  1110.             Circuit_Component component=bank.getTList().get(bank.getTList().size()-1).getConcatenationList().get(1);
  1111.             voltageMap.put(component, new ComponentVoltage2(220,bank.getTList().get(bank.getTList().size()-1).getConcatenationList().get(1).getOutputVoltage()));
  1112.             setElectric(Vinput,bank.getTList().get(bank.getTList().size()-1),true,Vinput,0,voltageMap);
  1113.         }
  1114.         tLast=bank.getTList().get(bank.getTList().size()-1);
  1115.         operateR(tLast);
  1116.         list=bank.sortArrayOutput(bank.getTList().get(bank.getTList().size()-1),list);
  1117.         Collections.sort(list, new ComponentComparator());
  1118.         showOut(list);
  1119.     }
  1120. }
  1121. class ComponentItemFactory{
  1122.     public static Circuit_Component createComponent(String component_Input) {
  1123.         if(component_Input.startsWith("VCC")) {
  1124.             return new PowerSupply(component_Input);
  1125.         } else if (component_Input.startsWith("GND")) {
  1126.             return new Ground("GND");
  1127.         } else if(component_Input.startsWith("K")) {
  1128.             return new Switch(component_Input);
  1129.         }else if(component_Input.startsWith("H")) {
  1130.             return new H(component_Input);
  1131.         }else if(component_Input.startsWith("F")) {
  1132.             return new F(component_Input);
  1133.         }else if(component_Input.startsWith("L")) {
  1134.             return new L(component_Input);
  1135.         }else if(component_Input.startsWith("B")) {
  1136.             return new B(component_Input);
  1137.         }else if(component_Input.startsWith("R")) {
  1138.             return new R(component_Input);
  1139.         }else if(component_Input.startsWith("D")) {
  1140.             return new D(component_Input);
  1141.         }else  if(component_Input.startsWith("S")) {
  1142.             return new S(component_Input);
  1143.         }else if(component_Input.startsWith("A")){
  1144.             return new A(component_Input);
  1145.         } else if (component_Input.startsWith("P")) {
  1146.             return new P(component_Input);
  1147.         }
  1148.         return null;
  1149.     }
  1150. }
  1151. public class Main {
  1152.     public static void main(String[] args) {
  1153.         Scanner scanner = new Scanner(System.in);
  1154.         HomeElectricalSystem system=HomeElectricalSystem.getInstance();
  1155.         system.TakeIn(scanner);
  1156.     }
  1157. }
复制代码
因为本学期最后一次了嘛,发出来看看也可以,(学弟们应该用的不是同套题目集吧)

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。




欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) Powered by Discuz! X3.4