Picking java back up and trying to familiarize myself with enum types. I'm trying to create an address book where user can create contacts. I've created everything already, but am hung up on setting a contact type (Family, Friends, Business, etc...) I've set up an enum class in a separate java class.
public class ContactType
{
public enum contactType
{
Family,
Church,
Friend,
BusninessColleague,
ServicePerson,
Customer,
Other
}
}
With my Contacts class looking like:
public class Contacts
{
private contactType contact;
private String name;
private String streetAddress;
private String city;
private String state;
private String zipCode;
private String phone;
private String email;
private String photo;
public Contacts ( )
{
contact = null;
name = "XXX XXX";
streetAddress = "XXX";
state = "XX";
zipCode = "00000";
phone = "XXX-XXXX";
email = "XXX@XXX.COM";
photo = "XXX.jpg";
}
public Contacts (ContactType contactType, String name, String streetAddress, String city,
String state, String zipCode, String phone, String email, String photo)
{
this.contact = contactType;
this.name = name;
this.streetAddress = streetAddress;
this.city = city;
this.state = state;
this.zipCode = zipCode;
this.phone = phone;
this.email = email;
this.photo = photo;
}
public ContactType getContactType ( )
{
return contact;
}
public void setContactType (ContactType input)
{
this.contact = input;
}
//rest of code
and finally my driver, it includes a menu (everything else works except for setting the contact type so i've just included that snippet for the sake of keeping it short):
switch (iSelection)
{
case 1:
c1 = new Contacts(); //creates a new contact
break;
case 2:
strContactType = JOptionPane.showInputDialog ("Please enter contact type (Family, Church, BusinessColleague, ServicePerson, Customer, or Other)");
contactType.valueOf(strContactType);
JOptionPane.showMessageDialog (null, strContactType);
c1.setContactType (strContactType);
break;
I know i've done something wrong here c1.setContactType(strContactType);
because i'm getting "The method setContactType(ContactType) in the type Contacts is not applicable for the arguments (String)" due to complete ignorance I don't know how to fix it to set the contactType to whatever the user inputs.