如题所述
第1个回答 2010-10-13
我用java写的~`
import java.sql.Date;
public class test {
private int id; //应该还要有id吧~~
private String name;
private boolean sex; //char是数据库里面建表时选择的类型
private Date birth; //birth应该是Date类型,在取值的时候可以选择to_String()
private int classes;
private float results;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public boolean isSex() {
return sex;
}
public void setSex(boolean sex) {
this.sex = sex;
}
public Date getBirth() {
return birth;
}
public void setBirth(Date birth) {
this.birth = birth;
}
public int getClasses() {
return classes;
}
public void setClasses(int classes) {
this.classes = classes;
}
public float getResults() {
return results;
}
public void setResults(float results) {
this.results = results;
}
public test(int id,String name,boolean sex,int classes,Date birth,float results){
this.id=id;
this.name=name;
this.sex=sex;
this.classes=classes;
this.birth=birth;
this.results=results;
}
}
import java.sql.Date;
public class test {
private int id; //应该还要有id吧~~
private String name;
private boolean sex; //char是数据库里面建表时选择的类型
private Date birth; //birth应该是Date类型,在取值的时候可以选择to_String()
private int classes;
private float results;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public boolean isSex() {
return sex;
}
public void setSex(boolean sex) {
this.sex = sex;
}
public Date getBirth() {
return birth;
}
public void setBirth(Date birth) {
this.birth = birth;
}
public int getClasses() {
return classes;
}
public void setClasses(int classes) {
this.classes = classes;
}
public float getResults() {
return results;
}
public void setResults(float results) {
this.results = results;
}
public test(int id,String name,boolean sex,int classes,Date birth,float results){
this.id=id;
this.name=name;
this.sex=sex;
this.classes=classes;
this.birth=birth;
this.results=results;
}
}
第2个回答 2010-10-13
/// <summary>
/// 学生类
/// </summary>
public class Student
{
private string name;
/// <summary>
/// 姓名
/// </summary>
public string Name
{
get { return name; }
set { name = value; }
}
private char sex;
/// <summary>
/// 性别
/// </summary>
public char Sex
{
get { return sex; }
set { sex = value; }
}
private DateTime brithDay;
/// <summary>
/// 生日
/// </summary>
public DateTime BrithDay
{
get { return brithDay; }
set { brithDay = value; }
}
private int classes;
/// <summary>
/// 班级
/// </summary>
public int Classes
{
get { return classes; }
set { classes = value; }
}
private float score;
/// <summary>
/// 成绩
/// </summary>
public float Score
{
get { return score; }
set { score = value; }
}
/// <summary>
/// 学生类无参构造器
/// </summary>
public Student()
{
}
/// <summary>
/// 学生类有参构造器
/// </summary>
/// <param name="name">姓名</param>
/// <param name="sex">性别</param>
/// <param name="brithDay">生日</param>
/// <param name="classes">班级</param>
/// <param name="score">成绩</param>
public Student(string name, char sex, DateTime brithDay, int classes, float score)
{
this.name = name;
this.sex = sex;
this.brithDay = brithDay;
this.classes = classes;
this.score = score;
}
}
/// 学生类
/// </summary>
public class Student
{
private string name;
/// <summary>
/// 姓名
/// </summary>
public string Name
{
get { return name; }
set { name = value; }
}
private char sex;
/// <summary>
/// 性别
/// </summary>
public char Sex
{
get { return sex; }
set { sex = value; }
}
private DateTime brithDay;
/// <summary>
/// 生日
/// </summary>
public DateTime BrithDay
{
get { return brithDay; }
set { brithDay = value; }
}
private int classes;
/// <summary>
/// 班级
/// </summary>
public int Classes
{
get { return classes; }
set { classes = value; }
}
private float score;
/// <summary>
/// 成绩
/// </summary>
public float Score
{
get { return score; }
set { score = value; }
}
/// <summary>
/// 学生类无参构造器
/// </summary>
public Student()
{
}
/// <summary>
/// 学生类有参构造器
/// </summary>
/// <param name="name">姓名</param>
/// <param name="sex">性别</param>
/// <param name="brithDay">生日</param>
/// <param name="classes">班级</param>
/// <param name="score">成绩</param>
public Student(string name, char sex, DateTime brithDay, int classes, float score)
{
this.name = name;
this.sex = sex;
this.brithDay = brithDay;
this.classes = classes;
this.score = score;
}
}
第3个回答 2010-10-12
#include<iostream>
#include<string>
using namespace std;
class student
{
string name;
char sex;
string birthday;
int classes;
float grate;
public:
void set_S();
};
void student ::set_S()
{
cout<<"姓名";
cin>>name;
cout<<"性别";
cin>>sex;
cout<<"出生日期";
cin>>brithday;
cout<<"班级";
cin>>classes;
cout<<"成绩";
cin>>grate;
}本回答被提问者采纳
#include<string>
using namespace std;
class student
{
string name;
char sex;
string birthday;
int classes;
float grate;
public:
void set_S();
};
void student ::set_S()
{
cout<<"姓名";
cin>>name;
cout<<"性别";
cin>>sex;
cout<<"出生日期";
cin>>brithday;
cout<<"班级";
cin>>classes;
cout<<"成绩";
cin>>grate;
}本回答被提问者采纳