TJETC Java实训02:Java原则特性及接口


1、printer

装配、抽象

没有、继承、聚合(类属性是类===接口<推荐>)

开闭原则(OCP):功能扩充的打开、对程序代码修改的关闭

基于抽象类 – 父类子类继承。

2、Computer

Keyboard、Mouse、Printer implements USB

++++++++++++++++

List list = new ArrayList(); Object

List<Student> list = new ArrayList<Student>();

list.add(Student对象)

list增删改查 – iterator

重写覆盖Object中方法(equals\clone\toString\finalize)

==========================

Map

++++++++++++++++++++++++++++++++

interface UserDAO UserDAOImpl UserDAO2Impl

public class UserOperate{

private UserDAO userDAO;

publice setter/getterUserDAO(UserDAO userDAO)

由源代码外部的配置文件制定
[java]
private User user;
public boolean userLogin(String userName, String userPassword){
user = userDAO.findByUserName(userName);
if(userPassword.equals(user.getUserPassword()))
return true;
else
return false;
}
}
[/java]

发表评论