In: Computer Science
Design a class that holds the following personal data: name and phone number. Write appropriate accessor and mutator methods. Also, design a program that creates two instances of the class. One instance should hold your information, and the other should hold your friends information. phone numbers should be fake.
public class Information {
private String name;
private String phoneNumber;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
}
class InformationTest {
public static void main(String[] args) {
Information me = new Information();
me.setName("ronaldo");
me.setPhoneNumber("777-777-7777");
Information other = new Information();
other.setName("messi");
other.setPhoneNumber("101-010-1010");
System.out.println("Name: " + me.getName() + ", Phone number: " + me.getPhoneNumber());
System.out.println("Name: " + other.getName() + ", Phone number: " + other.getPhoneNumber());
}
}
