Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2301_76699619
Java_573770
提交
5631fbf1
J
Java_573770
项目概览
2301_76699619
/
Java_573770
与 Fork 源项目一致
Fork自
inscode / Java
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
Java_573770
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
5631fbf1
编写于
4月 18, 2024
作者:
2
2301_76699619
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Thu Apr 18 23:01:00 CST 2024 inscode
上级
ff505d03
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
0 addition
and
141 deletion
+0
-141
Main.java
Main.java
+0
-141
未找到文件。
Main.java
浏览文件 @
5631fbf1
import
java.util.Arrays
;
import
java.util.Scanner
;
class
Person
{
private
String
name
;
private
String
address
;
private
String
phoneNumber
;
private
String
email
;
public
Person
(
String
name
,
String
address
,
String
phoneNumber
,
String
email
)
{
this
.
name
=
name
;
this
.
address
=
address
;
this
.
phoneNumber
=
phoneNumber
;
this
.
email
=
email
;
}
// Getters and Setters
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getAddress
()
{
return
address
;
}
public
void
setAddress
(
String
address
)
{
this
.
address
=
address
;
}
public
String
getPhoneNumber
()
{
return
phoneNumber
;
}
public
void
setPhoneNumber
(
String
phoneNumber
)
{
this
.
phoneNumber
=
phoneNumber
;
}
public
String
getEmail
()
{
return
email
;
}
public
void
setEmail
(
String
email
)
{
this
.
email
=
email
;
}
@Override
public
String
toString
()
{
return
"Name: "
+
name
+
", Address: "
+
address
+
", Phone: "
+
phoneNumber
+
", Email: "
+
email
;
}
}
class
Student
extends
Person
{
private
String
studentId
;
private
String
classStatus
;
private
String
college
;
private
double
englishScore
;
private
double
mathScore
;
private
double
computerScore
;
private
double
totalScore
;
public
Student
(
String
name
,
String
address
,
String
phoneNumber
,
String
email
,
String
studentId
,
String
classStatus
,
String
college
,
double
englishScore
,
double
mathScore
,
double
computerScore
)
{
super
(
name
,
address
,
phoneNumber
,
email
);
this
.
studentId
=
studentId
;
this
.
classStatus
=
classStatus
;
this
.
college
=
college
;
this
.
englishScore
=
englishScore
;
this
.
mathScore
=
mathScore
;
this
.
computerScore
=
computerScore
;
sum
();
}
// Getters and Setters
public
double
getEnglishScore
()
{
return
englishScore
;
}
public
void
setEnglishScore
(
double
englishScore
)
{
this
.
englishScore
=
englishScore
;
sum
();
}
public
double
getMathScore
()
{
return
mathScore
;
}
public
void
setMathScore
(
double
mathScore
)
{
this
.
mathScore
=
mathScore
;
sum
();
}
public
double
getComputerScore
()
{
return
computerScore
;
}
public
void
setComputerScore
(
double
computerScore
)
{
this
.
computerScore
=
computerScore
;
sum
();
}
public
double
getTotalScore
()
{
return
totalScore
;
}
// Methods
public
void
sum
()
{
totalScore
=
englishScore
+
mathScore
+
computerScore
;
}
public
int
compare
(
Student
other
)
{
return
Double
.
compare
(
this
.
totalScore
,
other
.
totalScore
);
}
public
double
testScore
()
{
return
(
englishScore
+
mathScore
+
computerScore
)
/
3
;
}
@Override
public
String
toString
()
{
return
super
.
toString
()
+
", StudentID: "
+
studentId
+
", Class Status: "
+
classStatus
+
", College: "
+
college
+
", Scores: [English: "
+
englishScore
+
", Math: "
+
mathScore
+
", Computer: "
+
computerScore
+
", Total: "
+
totalScore
+
"]"
;
}
}
class
StudentCommittee
extends
Student
{
private
String
responsibility
;
private
String
tenure
;
public
StudentCommittee
(
String
name
,
String
address
,
String
phoneNumber
,
String
email
,
String
studentId
,
String
classStatus
,
String
college
,
double
englishScore
,
double
mathScore
,
double
computerScore
,
String
responsibility
,
String
tenure
)
{
super
(
name
,
address
,
phoneNumber
,
email
,
studentId
,
classStatus
,
college
,
englishScore
,
mathScore
,
computerScore
);
this
.
responsibility
=
responsibility
;
this
.
tenure
=
tenure
;
}
@Override
public
double
testScore
()
{
return
super
.
testScore
()
+
3
;
}
@Override
public
String
toString
()
{
return
super
.
toString
()
+
", Responsibility: "
+
responsibility
+
", Tenure: "
+
tenure
;
}
}
public
class
Main
{
public
static
void
main
(
String
[]
args
)
{
Scanner
scanner
=
new
Scanner
(
System
.
in
);
Student
[]
students
=
new
Student
[
4
];
for
(
int
i
=
0
;
i
<
students
.
length
;
i
++)
{
System
.
out
.
println
(
"Enter details for student "
+
(
i
+
1
));
System
.
out
.
print
(
"Name: "
);
String
name
=
scanner
.
nextLine
();
System
.
out
.
print
(
"Address: "
);
String
address
=
scanner
.
nextLine
();
System
.
out
.
print
(
"Phone: "
);
String
phone
=
scanner
.
nextLine
();
System
.
out
.
print
(
"Email: "
);
String
email
=
scanner
.
nextLine
();
System
.
out
.
print
(
"Student ID: "
);
String
studentId
=
scanner
.
nextLine
();
System
.
out
.
print
(
"Class Status: "
);
String
classStatus
=
scanner
.
nextLine
();
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录