本文主要是介绍java里需要char的性别姓名_java程序改错(1)创建一个student类,包括的域有学号,班号,姓名,性别,年龄等,且都是private类型 (2...,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
java程序改错(1)创建一个student类,包括的域有学号,班号,姓名,性别,年龄等,且都是private类型 (2
关注:181 答案:3 mip版
解决时间 2021-01-13 06:46
提问者野战女神
2021-01-12 06:18
http://wenwen.sogou.com/z/q711025070.htm&__bd_tkn__=6bb8572b2a6cae204512aa3de4a436a3ca478cf38078338d51fed8133ea5c69d362ad36bb4bcda3b39bb3949f6bbe47087ac3af56e60b1f4e7eb60157958f4309e6fa8f95e0f03de0125277ad236c97f3f06ef717822ce8dd14c440c702e472dcb660b313db6a4d99e0e8eaccbdc8c0bcf3320f04da8具体题目见此网址
public class student
private static int count;
{
private int Snumber;
private int Sclass;
private string Sname;
private string Ssex;
private int Sage;
public student (int Snumber, int Sclass, string Sname, string Ssex,int Sage)
{
super();
this.Snumber=Snumber;
this.Sclass=Sclass;
this.Sname=Sname;
this.Ssex=Ssex;
this.Sage=Sage;
count++;
}
public static int GetExsitingStudentCount()
{
return count;
}
public int GetSnumber()
{
return Snumber;
}
public void SetSnumber(int Snumber)
{
this.Snumber=Snumber;
}
public int GetSclass()
{
return Sclass;
}
public void SetSclass(int Sclass)
{
this.Sclass=Sclass;
}
public string GetSname()
{
return Sname;
}
public void SetSname(string Sname)
{
this.Sname=Sname;
}
public String getSsexString() {
return sex == 'F' ? "男" : "女";
}
public char getSsex() {
return Ssex;
}
public void setSsex(char Ssex) {
this.Ssex = Ssex;
}
}
public int GetSage()
{
return Sage;
}
public void SetSage(int Sage)
{
this.Sage=Sage;
}
private String prop(String name, Object value, char sep) {
return sep + name + ":" + value;
}
public String toString() {
String desc = prop("学号", Snumber, '\0');
desc += prop("班号", Sclass, ',');
desc += prop("姓名", Sname, ',');
desc += prop("性别", getSexString(), ',');
desc += prop("年龄", Sage, ',');
return desc;
}
}
import student.Student;
public class StudentTest {
public static void main(String[] args) {
Student s1 = new Student("No.1", "T1", "张三", 'F', 14);
Student s2 = new Student("No.1", "T1", "马莉", 'M', 13);
println(s1);
println(s2);
s1.setSname("李四");
s1.setSage(12);
println("姓名", s1.getSname());
println("年龄", s1.getSage());
printlnSeparator();
if (s1.getSage() > s2.getSage()) {
println(s1);
} else
println(s2);
}
private static void printlnSeparator(){
System.out.println("=============================");
}
public static void println(Student s) {
println("学号", s.getSnumber());
println("班级", s.getSclass());
println("姓名", s.getSname());
println("性别", s.getSsexString());
println("年龄", s.getSage());
printlnSeparator();
}
public static void println(String prop, Object value) {
System.out.println(prop + ":" + value);
}
}
最佳答案
二级知识专家就当涐的真心喂了狗
2021-01-12 07:47
这个代码怎么这么多错误啊
改了下:
public class student
{
private static int count;
private int Snumber;
private int Sclass;
private String Sname;
private String Ssex;
private int Sage;
public student (int Snumber, int Sclass, String Sname, String Ssex,int Sage)
{
super();
this.Snumber=Snumber;
this.Sclass=Sclass;
this.Sname=Sname;
this.Ssex=Ssex;
this.Sage=Sage;
count++;
}
public static int GetExsitingStudentCount()
{
return count;
}
public int GetSnumber()
{
return Snumber;
}
public void SetSnumber(int Snumber)
{
this.Snumber=Snumber;
}
public int GetSclass()
{
return Sclass;
}
public void SetSclass(int Sclass)
{
this.Sclass=Sclass;
}
public String GetSname()
{
return Sname;
}
public void SetSname(String Sname)
{
this.Sname=Sname;
}
public String getSsexString() {
return Ssex.equals("F") ? "男" : "女";
}
public String getSsex() {
return Ssex;
}
public void setSsex(String Ssex) {
this.Ssex = Ssex;
}
public int GetSage()
{
return Sage;
}
public void SetSage(int Sage)
{
this.Sage=Sage;
}
private String prop(String name, Object value, char sep) {
return sep + name + ":" + value;
}
public String toString() {
String desc = prop("学号", Snumber, '\0');
desc += prop("班号", Sclass, ',');
desc += prop("姓名", Sname, ',');
desc += prop("性别", getSsexString(), ',');
desc += prop("年龄", Sage, ',');
return desc;
}
}
public class testt {
public static void main(String[] args) throws Exception {
student s1 = new student(1, 1, "张三", "F", 14);
student s2 = new student(2, 1, "马莉", "M", 13);
s1.SetSname("李四");
s1.SetSage(12);
println("姓名", s1.GetSname());
println("年龄", s1.GetSage());
printlnSeparator();
if (s1.GetSage() > s2.GetSage()) {
println(s1);
} else
{
println(s2);
}
}
private static void printlnSeparator(){
System.out.println("=============================");
}
public static void println(student s) {
println("学号", s.GetSnumber());
println("班级", s.GetSclass());
println("姓名", s.GetSname());
println("性别", s.getSsexString());
println("年龄", s.GetSage());
printlnSeparator();
}
public static void println(String prop, Object value) {
System.out.println(prop + ":" + value);
}
}
全部回答
1楼老酒街
2021-01-12 09:58
你这提问是神马意思?
2楼趁我还喜欢
2021-01-12 09:19
问的是啥问题
再看看别人怎么说的。
我要举报
如以上问答内容为低俗/色情/暴力/不良/侵权的信息,可以点下面链接进行举报,我们会做出相应处理,感谢你的支持!
→点此我要举报以上信息!←
推荐资讯
大家都在看
这篇关于java里需要char的性别姓名_java程序改错(1)创建一个student类,包括的域有学号,班号,姓名,性别,年龄等,且都是private类型 (2...的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!