1. 概述
2. 代码解析
- 在测试类上有详细说明
public interface ICourseInfo {
String getName();
BigDecimal getPrice();
}
public interface ICourseManager {
boolean buyCourse();
boolean refundCourse();
}
public class CourseImpl implements ICourseInfo, ICourseManager {
@Override
public String getName() {
return null;
}
@Override
public BigDecimal getPrice() {
return null;
}
@Override
public boolean buyCourse() {
return false;
}
@Override
public boolean refundCourse() {
return false;
}
}
public class SingleResponsibilityTest {
public static void main(String[] args) {
CourseImpl courseImpl = new CourseImpl();
ICourseInfo courseInfo = courseImpl;
courseInfo.getName();
ICourseManager courseManager = courseImpl;
courseManager.buyCourse();
}
}