/*
*copyright (c) 2015,
*All rights reserved
*The Author:王争取
*Finished Time:2015.3.23
*/
#include <iostream>
using namespace std;
class Student
{
public:
void setstudent(string,double,double);
void show();
void setName(string);
string getName();
double sum();
double average();
private:
string name;
double chinese;
double match;
};
void Student::setstudent(string nam,double chin,double mat)
{
name=nam;
chinese=chin;
match=mat;
}
double Student::sum()
{
return(chinese+match);
}
double Student::average()
{
return (sum()/2);
}
void Student::setName(string nam)
{
name=nam;
}
string Student::getName()
{
return name;
}
void Student::show()
{
cout<<"name: "<<name<<endl;
cout<<"scorce: "<<"chinese: "<<chinese<<" match: "<<match<<endl;
cout<<"sum: "<<sum()<<" average: "<<average()<<endl;
}
int main()
{
Student stu1,stu2;
stu1.setstudent("lin daiyu",98,96);
stu2.setstudent("jia baoyu",90,88);
stu1.show();
stu2.show();
stu1.setName("xue baochai");
stu1.show();
cout<<"stu1.name:"<<stu1.getName()<<endl;
cout<<"stu1.average:"<<stu1.average()<<endl;
return 0;
}