// // Supporting material for lecture 13 // - making a class and then using it // public class Person { private String firstName; private String surName; private int age; private Person spouse; public Person(String firstName,String surName,int age){ this.firstName = firstName; this.surName = surName; this.age = age; spouse = null; } public Person(String firstName,String surName){ this.firstName = firstName; this.surName = surName; this.age = 0; spouse = null; } public String toString(){ String s = firstName + " " + surName + " " + " age " + age; if (spouse != null) s = s + " married to " + spouse.firstName; return s; } public boolean isMarried(){return spouse != null;} public int getAge(){return age;} public String getName(){return firstName + " " + surName;} public void marry(Person x){this.spouse = x;x.spouse = this;} } // // NOTES // - we have 2 constructors // - naming convention of Classes, instance variables, methods such as toString, etc // - this // - null !!! //