Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
邓某人的父亲
Core Java 8th Learning
提交
ee40ee62
Core Java 8th Learning
项目概览
邓某人的父亲
/
Core Java 8th Learning
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Core Java 8th Learning
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
ee40ee62
编写于
1月 13, 2023
作者:
邓某人的父亲
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add new file
上级
59f62cae
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
61 addition
and
0 deletion
+61
-0
Java语言中的对象和类/EmployeeTest.java
Java语言中的对象和类/EmployeeTest.java
+61
-0
未找到文件。
Java语言中的对象和类/EmployeeTest.java
0 → 100644
浏览文件 @
ee40ee62
import
java.util.Date
;
import
java.util.GregorianCalendar
;
/**
* <strong> 2023-01-13 </strong> <br>
* This program tests the Employee class.
*
* @author Cay Horstmann
* @version 1.11 2004-02-19
*/
public
class
EmployeeTest
{
public
static
void
main
(
String
[]
args
)
{
// fill the staff array with three Employee objects
Employee
[]
staff
=
new
Employee
[
3
];
staff
[
0
]
=
new
Employee
(
"Carl Cracker"
,
75000
,
1987
,
12
,
15
);
staff
[
1
]
=
new
Employee
(
"Harry Hacker"
,
50000
,
1989
,
10
,
1
);
staff
[
2
]
=
new
Employee
(
"Tony Tester"
,
40000
,
1990
,
3
,
15
);
// raise everyone's salary by 5%
for
(
Employee
e
:
staff
)
e
.
raiseSalary
(
5
);
// print out information about all Employee objects
for
(
Employee
e
:
staff
)
System
.
out
.
println
(
"name="
+
e
.
getName
()
+
",salary="
+
e
.
getSalary
()
+
",hireDay="
+
e
.
getHireDay
());
}
}
class
Employee
{
private
String
name
;
private
double
salary
;
private
Date
hireDay
;
public
Employee
(
String
n
,
double
s
,
int
year
,
int
month
,
int
day
)
{
name
=
n
;
salary
=
s
;
GregorianCalendar
calendar
=
new
GregorianCalendar
(
year
,
month
-
1
,
day
);
// GregorianCalendar uses 0 for January
hireDay
=
calendar
.
getTime
();
}
public
String
getName
()
{
return
name
;
}
public
double
getSalary
()
{
return
salary
;
}
public
Date
getHireDay
()
{
return
hireDay
;
}
public
void
raiseSalary
(
double
byPercent
)
{
double
raise
=
salary
*
byPercent
/
100
;
salary
+=
raise
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录