<<< Classes of Objects and Instances of Objects     Index     UML Class Diagram Video Notes >>>

3. Object attributes


  • Using Java code to describe a class:

    
    public class Person {
        // Attributes
        private String name;
    
        private String address;
    
        // Java methods
        public String getName() {
            return name;
        }
    
        public void setName( String name_ ) {
            name = name_;
        }
    
        public String getAddress() {
            return address;
        }
    
        public void setAddress( String address_ ) {
            address = address_;
        }
    }
    
    
  • Using UML to model a class diagram:

     

    Person
    -name:String
    -address:String
    +getName:String
    +setName:void
    +getAddress:String
    +setAddress:void

<<< Classes of Objects and Instances of Objects     Index     UML Class Diagram Video Notes >>>