For a homework assignment, part of making the class that we use throughout the assignment requires me to create constructors that follow the guidelines
ContactInfo()
Default constructor and initializes a contact info with name = “unknown” and an empty list (length of zero)"
ContactInfo (String name, ArrayList<Phone> phoneNumber)
Constructor and initializes a contact info with the given name and the given list of phones."
This is our first assignment working with constructors and arraylists, and our textbook has little information on actually writing them as opposed to what they do.
This is what I've written so far.
import java.util.ArrayList;
import java.util.List;
public class ContactInfo {
public String name;
public ArrayList<Phone> phoneNums;
public ContactInfo() {
String name = "unknown";
ArrayList phoneNumber = new ArrayList<Phone>(0);
}
public ContactInfo(String name, ArrayList<Phone> phoneNumber) {
this.name = name;
this.phoneNumber = phoneNumber;
}
}
I am getting a "cannot find symbol variable phoneNumber" error, however I am pretty sure it is initialized and the method can access it. I am pretty confused on how to work constructors and complete the guidelines described at the top of the post. My professor is not willing to check his email over this Thanksgiving Break, so I cannot reach him for help.
Edit: We have another provided source file that is included with this code, however all the methods and variables are private (we aren't allowed to alter this file either), so I am not sure they will help.