Trouble understanding Object State, Behavior, and Identity?

前端 未结 5 1188
面向向阳花
面向向阳花 2021-01-30 11:42

I have been instructed by my professor to introduce myself on a page as if I were an object, and that I must address three things:
1) Object State, 2) Behavior, and 3) Ident

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-30 12:02

    All objects have three essential features:

    • state
    • behavior
    • identity

    An object's state is defined by the attributes of the object and by the values these have. In your case, name, age, gender

    The term "behavior" refers to how objects interact with each other, and it is defined by the operations an object can perform. In your case, student object, can do some activity?

    student.getResults();
    
    • Identity:

    Even objects with the same properties and behavior have their own individual identity.

    For Example,

    2 blue station wagons that were built in the same year by the same manufacturer are still separate and unique cars.

    The identity of an object is independent of its attributes or operations. So an object will retain its identity no matter what values its properties have.

提交回复
热议问题