zoukankan      html  css  js  c++  java
  • 关于3.1 jmu-Java-03面向对象基础-01-构造函数与toString (3 分)

    PTA显示Compiler did not create the expected binary
    不知所措
     
    package nn;
     import java.util.Scanner;    
     class Person{       
         private String name = null;
         private int age = 0;
         private boolean gender = false;
         private int id = 0;
         
         public Person() {    
             System.out.println("This is constructor");
             System.out.println(name+","+age+","+gender+","+id);
             System.out.println("Person [name="+name+", age="+age+", gender="+gender+", id="+id+"]");
         }
         
         public Person(String name, int age, boolean gender) {   
             this.name = name;
             this.age = age;
             this.gender = gender;
         }
           
         public String toString() {   
             System.out.println("Person [name="+this.name+", age="+this.age+", gender="+this.gender+", id="+0+"]");
             return name;
         }
         public String getName(){    
              return name;
          }
          public void setName(String name){
              this.name=name;
          }
          public int getAge(){
              return age;
          }
          public void setAge(int age){
              this.age=age;
          }
          public boolean getGender(){
              return gender;
          }
          public void setGender(boolean gender){
              this.gender=gender;
          }
          public int getId(){
              return id;
          }
          public void setId(int id){
              this.id=id;
          }
     
         public static void main(String[] args) {
             Scanner reader = new Scanner(System.in);
             int n = reader.nextInt();       
             Person[] per = new Person[n];     
             for(int i=0; i<per.length; i++) {   
                 String name = reader.next();
                 int age = reader.nextInt();
                 boolean genter = reader.nextBoolean();
                 per[i] = new Person(name,age,genter);
             }
            for(int x=per.length-1; x>=0;x--){ 
                 per[x].toString();
             }
             
             per.toString();
             Person person = new Person(); 
         }
         }
     
     
     
  • 相关阅读:
    半夜删你代码队 Day6冲刺
    半夜删你代码队 Day5冲刺
    半夜删你代码队 Day4冲刺
    半夜删你代码队 Day3冲刺
    Scrum 冲刺博客集合
    团队项目6——复审与事后分析
    Alpha阶段项目复审
    事后Postmortem会议
    团队作业5-测试与发布
    Scrum 冲刺第七天
  • 原文地址:https://www.cnblogs.com/zlshy/p/11524054.html
Copyright © 2011-2022 走看看