黑马程序员技术交流社区

标题: day09练习2 [打印本页]

作者: gcno93    时间: 2016-9-6 22:26
标题: day09练习2
需求二:
                具体事物:基础班学生,就业班学生
                共性:姓名,年龄,学习
                特性:
                        基础班学生学JavaSE
                        就业班学生学Android
public class Demo02 {
        public static void main(String[] args) {
                BaseStudent b=new BaseStudent("aa",12);
                b.study();
                JiuYeStudent j=new JiuYeStudent();
                j.study();
        }
}
abstract class Student{
        private String name;
        private int age;
        public abstract void study();
       
        public Student() {
                super();
        }

        public Student(String name, int age) {
                super();
                this.name = name;
                this.age = age;
        }

        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;
        }
       
       
}
class BaseStudent extends Student{
        public BaseStudent(){
                super();
        }
        public BaseStudent(String name, int age) {
                super(name,age);
        }
        @Override
        public void study() {
                // TODO Auto-generated method stub
                System.out.println("基础班学生学JavaSE");
        }
}

class JiuYeStudent extends Student{
        public JiuYeStudent(){
                super();
        }
        public JiuYeStudent(String name, int age) {
                super(name,age);
        }
        @Override
        public void study() {
                // TODO Auto-generated method stub
                System.out.println("就业班学生学Android");
        }
}




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2