/** * A contact has a name and a phone number. * * @author Phill Conrad * @version 05/18/2011 */ public class Contact { // instance variables private String name; private long phoneNum; // represent phone number as an integer // use long so we have enough digits /** * Constructor for objects of class Contact * @param theName the name of the contact * @param thePhoneNumber the phone number for the contact */ public Contact(String theName, long thePhoneNumber) { this.name = theName; this.phoneNum = thePhoneNumber; } /** Get the name * @return name of contact */ public String getName() { return this.name; } /** Get the phone number * @return the phone number of the contact */ public long getPhoneNumber() { return this.phoneNum; } /** Set the name * @param newName new name of the contact */ public void setName(String newName) { this.name = newName; } /** Set the phoneNumber * @param newPhoneNumber new phone number of the contact */ public void setPhoneNumber(long newPhoneNumber) { this.phoneNum = newPhoneNumber; } /* public String toString() { // Return a nicely formatted string version of the // object--something you could pass to System.out.println // as a parameter. But DON'T use System.out.println---just // return the value. return ""; // @@@ STUB... remove when you implement method } */ public static void main (String [] args) { Contact c1 = new Contact ("Steve Jobs",8002752273L); // L for long Contact c2 = new Contact ("Barack Obama",2024561414L); // L for long System.out.println("c1 =" + c1); System.out.println("c2 =" + c2); } }