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

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 小b,试试就试试 中级黑马   /  2016-7-28 22:22  /  369 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

        学生类Student
                        属性:语文成绩chinese,数学成绩math,英语成绩english
                        行为:求总成绩的方法getSum()

class Studnt {
        public static void main(String[] args) {
                Studentl p =new Studentl();
                p.setChinese(88);
                p.setMath(98);
                p.setEnglish(78);
                System.out.println(p.getChinese()+"  "+p.getMath()+"  "+p.getEnglish()+"  "+p.getSum() );
                }
}

class Studentl{
        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.math =math;
        }
        public int getMath()
        {
                return math;
        }

       
        public void setEnglish(int english)
        {
                this.english =english;
        }
        public int getEnglish()
        {
                return english;
        }
       
        public int getSum(){
        return chinese+math+english;
        }       
}

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马