发表于: 2019-10-25 21:28:54
1 1035
今天完成的事情:基础的学习 跑通了JDBC
学习面向对象,多态,练习代码
class Test3_Employee {
public static void main(String[] args) {
Coder c = new Coder("德玛西亚","007",8000);
c.work();
Manager m = new Manager("苍老师","9527",3000,20000);
m.work();
}
}
abstract class Employee {
private String name; //姓名
private String id; //工号
private double salary; //工资
public Employee() {} //空参构造
public Employee(String name,String id,double salary) {
this.name = name;
this.id = id;
this.salary = salary;
}
public void setName(String name) { //设置姓名
this.name = name;
}
public String getName() { //获取姓名
return name;
}
public void setId(String id) { //设置id
this.id = id;
}
public String getId() { //获取id
return id;
}
public void setSalary(double salary) { //设置工资
this.salary = salary;
}
public double getSalary() { //获取工资
return salary;
}
public abstract void work();
}
//程序员
class Coder extends Employee {
public Coder() {} //空参构造
public Coder(String name,String id,double salary) {
super(name,id,salary);
}
public void work() {
System.out.println("我的姓名是:" + this.getName() + ",我的工号是:" + this.getId() + ",我的工资是:"
+ this.getSalary() + ",我的工作内容是敲代码");
}
}
//项目经理
class Manager extends Employee {
private int bonus; //奖金
public Manager() {} //空参构造
public Manager(String name,String id,double salary,int bonus) {
super(name,id,salary);
this.bonus = bonus;
}
public void work() {
System.out.println("我的姓名是:" + this.getName() + ",我的工号是:" + this.getId() + ",我的工资是:"
+ this.getSalary() + ",我的奖金是:" + bonus + ",我的工作内容是管理");
}
}
明天计划的事情:学习SPRING
遇到的问题:
出了些BUG 用必应后找到了办法
收获:
学习了一点线程的知识
public class Demo3_Timer {
/**
* @param args
* @throws InterruptedException
*/
public static void main(String[] args) throws InterruptedException {
Timer t = new Timer();
//在指定时间安排指定任务
//第一个参数,是安排的任务,第二个参数是执行的时间,第三个参数是过多长时间再重复执行
t.schedule(new MyTimerTask(), new Date(188, 6, 1, 14, 22, 50),3000);
while(true) {
Thread.sleep(1000);
System.out.println(new Date());
}
}
}
class MyTimerTask extends TimerTask {
@Override
public void run() {
System.out.println("起床背英语单词");
}
}
评论