Trying to add the object member to the ArrayList loggedInList when logging into the Website class.
public class Website
{
// The name of the website.
private String name;
// The number of hits on the website.
public int hits;
// The amount of money taken at the checkout.
private double salesTotal;
//
private ArrayList<Member> loggedInList;
Is the code for my Website class.
public Website(String newName)
{
// Intialises the name of the website.
name = newName;
// Intialises the number of hits on the site.
hits = 0;
// Intialises the amount of money taken at the checkout.
salesTotal = 0;
//
loggedInList = new ArrayList<Member>();
}
Is the constructor for the Website class.
public void memberLogin(Member member)
{
member.setLoginStatus(true);
member.setWebsite(this);
System.out.println(name + " welcomes member " + member.getMembershipNumber() + "," + " you are now logged in.");
member.setWebsite(this);
hits +=1;
loggedInList.add(member);
}
Is the method which SHOULD add the current member into the ArrayList.
The error I get is a NullPointerException on the line:
loggedInList.add(member);
I honestly have no clue why.