add new files
This commit is contained in:
parent
f9788e9a7d
commit
bd871d68e0
51
Employee.java
Normal file
51
Employee.java
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
package com.powernode.spring6;
|
||||||
|
|
||||||
|
public class Employee {
|
||||||
|
private int id;
|
||||||
|
private String name;
|
||||||
|
private int level;
|
||||||
|
private Boolean isBoss;
|
||||||
|
|
||||||
|
private Employee(int id, String name, int level, Boolean isBoss) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
this.level = level;
|
||||||
|
this.isBoss = isBoss;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLevel() {
|
||||||
|
return level;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getBoss() {
|
||||||
|
return isBoss;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBoss(Boolean boss) {
|
||||||
|
if( boss && level > 25) {
|
||||||
|
isBoss = boss;
|
||||||
|
} else if (!boss && level < 25) {
|
||||||
|
isBoss = boss;
|
||||||
|
} else {
|
||||||
|
System.out.println("boss can only be person who level is higher than 25");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Employee staticTest(int id, String name, int level) {
|
||||||
|
return new Employee(id, name, level, level > 25);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Employee employee = Employee.staticTest(1,"Dan",27);
|
||||||
|
System.out.println(employee.isBoss);
|
||||||
|
}
|
||||||
|
}
|
@ -42,6 +42,7 @@ public class LeapYear {
|
|||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
System.out.println("Please enter command line arguments.");
|
System.out.println("Please enter command line arguments.");
|
||||||
System.out.println("e.g. java Year 2000");
|
System.out.println("e.g. java Year 2000");
|
||||||
|
System.out.println("aaa 2000 cccc");
|
||||||
}
|
}
|
||||||
for (int i = 0; i < args.length; i++) {
|
for (int i = 0; i < args.length; i++) {
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user