using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace InteractionObject
{
class Program
{
class Student
{
string id;
string name;
int scredits;
Course course;
public Student(string id, string name, int scredits, Course course)
{
this.id = id;
this.name = name;
this.scredits = scredits;
this.course = course;
}
public void UpdateCredit()
{
scredits += course.Credits;
}
public void display()
{
Console.WriteLine("该生的学号是{0},姓名是{1},已选择了《{2}》课,这门课的课程号是{3},{4}学分,由{5}讲授,现在该生的总学分数是{6}"
,id,name,course.Name,course.Cid,course.Credits,course.Teacher,scredits);
}
}
class Course
{
string cid;
string cname;
int credits;
string teacher;
public Course(string cid,string cname,int credits,string teacher)
{
this.cid = cid;
this.cname = cname;
this.credits = credits;
this.teacher = teacher;
}
public string Cid
{
get { return cid; }
}
public string Name
{
get { return cname; }
}
public int Credits
{
get { return credits; }
}
public string Teacher
{
get { return teacher; }
}
}
static void Main(string[] args)
{
Course c = new Course("Scl178","高阶英语",4,"Marry");
Student s = new Student("101","王明",30,c);
s.UpdateCredit();
s.display();
}
}
}