You want to create a program for the management of a telephone book. For each person are provided for the following personal information:Surname Name Title E-mail address (can not contain spaces and must contain the @ symbol) Company PositionFor every person you can store the following telephone numbers (one for each category)Home Office Mobile Phone.You can also store a list of other phone numbers. For each of the other numbers, you must store over to the phone number a description of the number.
Here it is a homework I have to make for this evening in Java. My issue is how I can implement the various category: Home,Office,ecc...Which is the best solution to implement those category? maybe an enum?
Here it is my implementation:
import java.util.*;
public class Persona {
private String Name;
private String surname;
private String title;
private String mail_addr;
private String company
private String position;
private Phone homePhone;
private Phone officePhone;
private Phone mobilePhone;
private Collection<Phone> otherphonesList
public Persona(String n,String s,String t,String m,String c,String p,Phone hp,Phone of,Phone mp,Collection<Phone> otherphones)
{
name=n;
surname=s;
title=t;
mail_addr=m;
company=c;
position=p;
homePhone=hp;
officePhone=of;
mobilePhone=mp;
otherphonesList=new ArrayList<Phone>(otherphones);
}
public String getName()
{
return name;
}
public String getSurname()
{
return surname;
}
public String getTitle()
{
return title;
}
public String getMail()
{
return mail_addr;
}
public String getCompany()
{
return company;
}
public String getPosition()
{
return position;
}
}
public class Phone {
private String phone;
private String description;
public Phone(String phone,String description)
{
this.phone=phone;
this.description=description;
}
public String getPhone()
{
return phone;
}
public String getDescription()
{
return description;
}
}
titlefield :)