java - Trouble understanding Object State, Behavior, and Identity? -


i have been instructed professor introduce myself on page if object, , must address 3 things. object state, behavior, , identity. however, still confused how go doing this. (i have read 3 attributes must address, don't know how apply person). example, told dog have states, such name, color, , breed; behaviors, such walking, barking, or wagging tail. similar to:

student me = new student(); system.out.println(me.getname()); //a state? system.out.println(me.getcurrentactivity()); //a behavior? (if return watching tv or something)  system.out.println(me.get....()); //??? 

or getting wrong idea here?

characteristics of objects are:

state: what objects have, student have first name, last name, age, etc

behavior: what objects do, student attend course "java beginners"

identity: what makes them unique, student have student-id-number, or email unique. (this important when implementing equals method, determine if objects different or not)

student john = new student("john"); john.setcurrentactivity("learning java"); john.setage(21); john.setweight(173); john.setaddress(...); john.sethobbies(...); 

and can figure out getters.

public class student {     private string name;     private int    age;     //etc      // construct new student      public student(string name) {         this.name   = name;     }      public setage(int age) {         this.age   = age;     }      public int getage() {         return age;     } } 

an illustration of car object, found might some...

car state:

  • speed
  • rpm
  • gear
  • direction
  • fuel level
  • engine temperature

behaviors:

  • change gear
  • go faster/slower
  • go in reverse
  • stop
  • shut-off

identity:

  • vin
  • license plate

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -