Solution to implement category in Java

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
Position
For 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 otherphonesList public Persona(String n,String s,String t,String m,String c,String p,Phone hp,Phone of,Phone mp,Collection otherphones) { name=n; surname=s; title=t; mail_addr=m; company=c; position=p; homePhone=hp; officePhone=of; mobilePhone=mp; otherphonesList=new ArrayList(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; } }
and don't forget the title field :)

以上就是Solution to implement category in Java的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏