Compare commits

...

8 Commits

Author SHA1 Message Date
bd871d68e0 add new files 2025-01-08 23:19:45 +08:00
f9788e9a7d Merge branch 'main' of ssh://kuanslab.com:23/tiqin/git_hub_happy_hour 2025-01-04 12:41:19 +08:00
2eb89779b6 Sync with qintian's homewrok and add new sample 2025-01-04 12:40:57 +08:00
1e3aa2f3b3 add merge 2025-01-02 23:33:28 +08:00
9accb457d2 add xxxxxxxxxx 2025-01-02 23:30:18 +08:00
191212ec5d add newline 2025-01-02 23:29:23 +08:00
cf91111056 conflict resolved 2025-01-02 23:26:07 +08:00
38d6fbc00c luanma 2025-01-02 23:19:57 +08:00
4 changed files with 118 additions and 1 deletions

51
Employee.java Normal file
View 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);
}
}

View File

@ -1,5 +1,6 @@
public class HelloWorld { public class HelloWorld {
public static void main(String[] args) { public static void main(String[] args) {
System.out.println("Hello tian!!!"); System.out.println("笑笑笑笑笑笑笑笑笑");
System.out.println("Hello, World");
} }
} }

57
LeapYear.java Normal file
View File

@ -0,0 +1,57 @@
/** Class that determines whether or not a year is a leap year.
* @author YOUR NAME HERE
*/
public class LeapYear {
/** Calls isLeapYear to print correct statement.
* @param year to be analyzed
*/
private static void checkLeapYear(int year) {
if (isLeapYear(year)) {
System.out.printf("%d is a leap year.\n", year);
} else {
System.out.printf("%d is not a leap year.\n", year);
}
}
/**
* Method check if year is leap
*/
public static boolean isLeapYear(int year) {
if (year % 400 == 0) {
return true;
} else if (year % 100 != 0 && year % 4 == 0) {
return true;
} else {
return false;
}
}
public static void countDaysInYear(int year) {
if (isLeapYear(year)) {
System.out.println("366 days");
} else {
System.out.println("365 days");
}
}
/** Must be provided an integer as a command line argument ARGS. */
public static void main(String[] args) {
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 {
int year = Integer.parseInt(args[i]);
checkLeapYear(year);
countDaysInYear(year);
} catch (NumberFormatException e) {
System.out.printf("%s is not a valid number.\n", args[i]);
}
}
}
}

8
Test.java Normal file
View File

@ -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);
}
}