标签:pack integer interface rri style 实体类 system new 获取
1 课程讲解
2 代码coding
1 课程讲解
2 代码coding
2.1 基类
测试类:
package com.geely.design.principle.openclose; public class TestJavaCourse { public static void main(String[] args) { Icourse icourse = new JavaCourse(96,"java开发教程",298.00); System.out.println("购买课程编号为:"+icourse.getCourseId()+";课程名称为:"+icourse.getCourseName()+";课程价格为:"+icourse.getCourcePrice()); } }
实体类:
package com.geely.design.principle.openclose; public class JavaCourse implements Icourse { private Integer courseId; private String courseName; private Double coursePrice; public JavaCourse(Integer courseId, String courseName, Double coursePrice) { this.courseId = courseId; this.courseName = courseName; this.coursePrice = coursePrice; } @Override public Integer getCourseId() { return this.courseId; } @Override public String getCourseName() { return this.courseName; } @Override public Double getCourcePrice() { return this.coursePrice; } }
接口:
package com.geely.design.principle.openclose; public interface Icourse { Integer getCourseId();//获取课程ID String getCourseName();//获取课程名称 Double getCourcePrice();//获取课程价格 }
打印日志:
购买课程编号为:96;课程名称为:java开发教程;课程价格为:298.0
Process finished with exit code 0
标签:pack integer interface rri style 实体类 system new 获取
原文地址:https://www.cnblogs.com/1446358788-qq/p/10959966.html