简单的java小程序,求大神帮忙编一下,着急
3个回答
展开全部
public class Student {
private String name;// 姓名
private int age;// 年龄
private boolean sex;// 性别:1男,0女
private int score;// 成绩
public Student(String name, int age, boolean sex, int score) {
super();
this.name = name;
this.age = age;
this.sex = sex;
this.score = score;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getSex() {
return sex ? "男" : "女";
}
public void setSex(boolean sex) {
this.sex = sex;
}
public int getScore() {
return score;
}
public void setScore(int score) {
this.score = score;
}
@Override
public String toString() {
return name + "[年龄:" + age + ", 性别:" + getSex() + ", 成绩: " + score + "]\n";
}
public static void main(String[] args) {
Student student = new Student("黄世仁", 24, true, 59);
System.out.println(student.getName());
System.out.println(student.getAge());
System.out.println(student.getSex());
System.out.println(student.getScore());
System.out.println(student);
}
}
展开全部
package power.guquan.base;
public class Student {
String name;
int age;
boolean sex;
int score;
public Student(){
}
public Student(String name,int age,boolean sex,int score){
this.name = name;
this.age = age;
this.sex = sex;
this.score = score;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public boolean isSex() {
return sex;
}
public void setSex(boolean sex) {
this.sex = sex;
}
public int getScore() {
return score;
}
public void setScore(int score) {
this.score = score;
}
public static void main(String[] args) {
Student st = new Student("黄世仁",24,true,59);
System.out.println(st.getName()+","+st.getAge()+","+st.isSex()+","+st.getScore());
}
}
public class Student {
String name;
int age;
boolean sex;
int score;
public Student(){
}
public Student(String name,int age,boolean sex,int score){
this.name = name;
this.age = age;
this.sex = sex;
this.score = score;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public boolean isSex() {
return sex;
}
public void setSex(boolean sex) {
this.sex = sex;
}
public int getScore() {
return score;
}
public void setScore(int score) {
this.score = score;
}
public static void main(String[] args) {
Student st = new Student("黄世仁",24,true,59);
System.out.println(st.getName()+","+st.getAge()+","+st.isSex()+","+st.getScore());
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你这简单到没朋友了,还不自己敲一下
追问
不会
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询