A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

250034275

中级黑马

  • 黑马币:38

  • 帖子:67

  • 精华:0

class F {
        public static void main(String[] args) {
                Student a = new Student();
                a.setChinese(99);
                System.out.println(a.getChinesee());
                setMath(108);
                System.out.println(a.getMath());
                setEnglish(106);
                System.out.println(a.getEnglish());
                System.out.println(a.getSum());
        }
}
class Student {
        private int chinese;
        private int math;
        private int english;
        public void setChinese(int chinese) {
                this.chinese = chinese;
        }
        public int getChinese() {
                return chinese;
        }
        public void setMath(int math) {
                this.chinese = chinese;
        }
        public int getMath() {
                return math;
        }
        public void setEnglish(int english) {
                this.english = english;
        }
        public int getEnglish() {
                return english;
        }
        public int getSum(int chinese,int math,int english ) {
                return chinese+math+english;
        }

}

4 个回复

正序浏览
本帖最后由 lvlup200 于 2016-3-18 17:10 编辑
  1. class F {
  2.     public static void main(String[] args) {
  3.             Student a = new Student();
  4.             a.setChinese(99);
  5.             System.out.println(a.getChinese());
  6.             a.setMath(108);
  7.             System.out.println(a.getMath());
  8.             a.setEnglish(106);
  9.             System.out.println(a.getEnglish());
  10.             System.out.println(a.getSum(a.getChinese(),a.getMath(),a.getEnglish()));
  11.     }
  12. }
  13. class Student {
  14.     private int chinese;
  15.     private int math;
  16.     private int english;
  17.    
  18.     public void setChinese(int chinese) {
  19.             this.chinese = chinese;
  20.     }
  21.     public int getChinese() {
  22.             return chinese;
  23.     }
  24.    
  25.     public void setMath(int math) {
  26.             this.math = math;
  27.     }
  28.     public int getMath() {
  29.             return math;
  30.     }
  31.     public void setEnglish(int english) {
  32.             this.english = english;
  33.     }
  34.     public int getEnglish() {
  35.             return english;
  36.     }
  37.     public int getSum(int chinese,int math,int english ) {
  38.             return chinese+math+english;
  39.     }
  40. }
复制代码
错误地方有,打字打错的比如:Chinese,;     有没有加对象. 的  比如 a.    还有没有加参数的 ,比如 getSum();  

回复 使用道具 举报
怪人长 发表于 2016-3-17 09:53
敲代码是个细致活儿,切不可粗心大意,up应该没有使用编译工具吧,使用了编译工具的话,好多编译上的错误就 ...

O(∩_∩)O谢谢
回复 使用道具 举报
敲代码是个细致活儿,切不可粗心大意,up应该没有使用编译工具吧,使用了编译工具的话,好多编译上的错误就会有提示出来的。愿楼主早日取得真经【】。
回复 使用道具 举报
  1. public class F {
  2.         public static void main(String[] args) {
  3.                 Student a = new Student();
  4.                 a.setChinese(99);
  5.                 System.out.println(a.getChinese());
  6.                 a.setMath(108);
  7.                 System.out.println(a.getMath());
  8.                 a.setEnglish(106);
  9.                 System.out.println(a.getEnglish());
  10.                 System.out.println(a.getSum());
  11.         }
  12. }

  13. class Student {
  14.         private int chinese;
  15.         private int math;
  16.         private int english;

  17.         public int getChinese() {
  18.                 return chinese;
  19.         }

  20.         public void setChinese(int chinese) {
  21.                 this.chinese = chinese;
  22.         }

  23.         public int getMath() {
  24.                 return math;
  25.         }

  26.         public void setMath(int math) {
  27.                 this.math = math;
  28.         }

  29.         public int getEnglish() {
  30.                 return english;
  31.         }

  32.         public void setEnglish(int english) {
  33.                 this.english = english;
  34.         }

  35.         public int getSum() {
  36.                 return chinese + math + english;
  37.         }
  38. }
复制代码


回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马