From bd871d68e03d2b1b199fe5c563d43c8a7754d808 Mon Sep 17 00:00:00 2001 From: Jason Lu Date: Wed, 8 Jan 2025 23:19:45 +0800 Subject: [PATCH] add new files --- Employee.java | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ LeapYear.java | 1 + Test.java | 8 ++++++++ 3 files changed, 60 insertions(+) create mode 100644 Employee.java create mode 100644 Test.java diff --git a/Employee.java b/Employee.java new file mode 100644 index 0000000..8110153 --- /dev/null +++ b/Employee.java @@ -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); + } +} diff --git a/LeapYear.java b/LeapYear.java index dac9c29..a72241a 100644 --- a/LeapYear.java +++ b/LeapYear.java @@ -42,6 +42,7 @@ public class LeapYear { if (args.length < 1) { System.out.println("Please enter command line arguments."); System.out.println("e.g. java Year 2000"); + System.out.println("aaa 2000 cccc"); } for (int i = 0; i < args.length; i++) { try { diff --git a/Test.java b/Test.java new file mode 100644 index 0000000..a19a0e5 --- /dev/null +++ b/Test.java @@ -0,0 +1,8 @@ +package com.powernode.spring6; + +public class Test { + public static void main(String[] args) { + Employee bruce = Employee.staticTest(2,"bulusi",24); + bruce.setBoss(true); + } +}