用java编写程序。

                用Java语言编写

1.编写一个课程类Course
(1)课程类的属性有:课程名称,课程课时,课程类型(基础课、专业基础课、专业课、选修课)、课程内容(以数组体现);(2)课程类的方法有:课程学习(抽象方法),显示课程内容,各属性的get和set方法;(3)完成课程类的构造方法
2.编写一个java课程类JavaCourse继承Course类
(1)完成构造方法编写(2)重写课程学习函数:在该函数中可以根据输入的数字选择学习的内容,(学习内容有:1.冒泡排序法,2.剪刀石头布,3.抽取幸运观众),3个学习内容编写3个对应的方法,完成相应的功能。(3个功能都要实现)

public abstract class Course {
    /**
     * 课程名称
     */
    private String name;
    /**
     * 课时
     */
    private int count;

    /**
     * 课程类型
     */
    private String type;

    /**
     * 课程内容
     */
    private CourseContent[] content;

    public Course() {
    }

    public Course(String name, int count, String type, CourseContent[] content) {
        this.name = name;
        this.count = count;
        this.type = type;
        this.content = content;
    }

    public abstract void study();

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public CourseContent[] getContent() {
        return content;
    }

    public void setContent(CourseContent[] content) {
        this.content = content;
    }

    public interface CourseContent {

        void doStudy();
    }

    public static class JavaCourse extends Course {

        public JavaCourse() {
        }

        public JavaCourse(String name, int count, String type, CourseContent[] content) {
            super(name, count, type, content);
        }

        @Override
        public void study() {
            Scanner scanner = new Scanner(System.in);
            System.out.println("请输入需要学习的内容:");
            int i = scanner.nextInt();
            if (i < 0 || i >= getContent().length) {
                System.out.println("暂时没有该学习内容!");
                return;
            }
            getContent()[i].doStudy();

        }
    }

    public static void main(String[] args) {
        JavaCourse javaCourse = new JavaCourse("Java", 20, "专业基础", new CourseContent[]{new CourseContent() {
            @Override
            public void doStudy() {
                System.out.println("冒泡排序");
            }
        }, new CourseContent() {
            @Override
            public void doStudy() {
                System.out.println("剪刀石头布");
            }
        }, new CourseContent() {
            @Override
            public void doStudy() {
                System.out.println("抽取幸运观众");
            }
        }});
        javaCourse.study();

    }
}