1.类图的概念及组成
类图是描述类、接口已经他们之间关系的图,它显示了系统中各个类的静态结构,是一种静态模型。
2.种类元素(类和接口)
4种关系(依赖关系、实现关系、泛化关系和关联关系)。
3.类的概念与表示符号
类和对象的关系:比如”人类“就是一个类,那么具体的某个人”张三“就是”人类“这个类的对象,而”名字、年龄“等信息就是对象的属性,人的动作比如”吃饭、穿衣、睡觉“等就是对象的操作。总之类就是有相同特征的事物集合,而对象就是类的一个具体实例。同时类有多态和继承,例如”人类“可以分为”男人、女人“。
类的概念:类是具有相同属性和行为的对象集合。
例如定义一个Student类:
class student{ //定义学生类
public string name;
private int englishScore;
private int mathScore;
private int computerScore;
public int sumScore;
public student(string x, int y, int z, int k){
name = x;
englishScore = y;
mathScore = z;
computerScore =k;
}
public void sum(){
sumScore = englishScore + mathScore + computerScore;
}
}
对应的类图:
类的符号: