First off let me say that I am new to Java and I have researches about this error as it seems it's a common one, but I still haven't found the solution. Here is my code:
public class Test3 {
public static void main(String[] args) {
WhiteHouseTour tour = new WhiteHouseTour();
System.out.println(tour.getRooms( ));
System.out.println();
System.out.println(tour);
Visitor v1 = new Visitor("Smirnov, Alex", "M", 35, "Russia");
Visitor v2 = new Visitor("Smith, Stan", "M", 31, "United States");
Visitor v3 = new Visitor("Malone, Maggie", "F", 32, "United States");
Visitor v4 = new Visitor("Zhao, George", "M", 29, "China");
Visitor v5 = new Visitor("Whiting, Whitney", "F", 32, "Canada");
tour.setVisitor(v1);
tour.setVisitor(v2);
tour.setVisitor(v3);
tour.setVisitor(v4);
}
}
And here is my code from the source file that sets the visitors:
public Visitor[] getVisitors( )
{
return visitors;
}
public void setVisitors(Visitor[] theVisitors)
{
visitors = theVisitors;
}
public int getNumVisitors( )
{
return numVisitors;
}
public void setNumVisitors(int theNumVisitors)
{
numVisitors = theNumVisitors;
}
And the error I am getting is this:
Test3.java:20: error: cannot find symbol
tour.setVisitor(v1);
^
symbol: method setVisitor(Visitor)
location: variable tour of type WhiteHouseTour
Test3.java:21: error: cannot find symbol
tour.setVisitor(v2);
^
symbol: method setVisitor(Visitor)
location: variable tour of type WhiteHouseTour
Test3.java:22: error: cannot find symbol
tour.setVisitor(v3);
^
symbol: method setVisitor(Visitor)
location: variable tour of type WhiteHouseTour
Test3.java:23: error: cannot find symbol
tour.setVisitor(v4);
^
symbol: method setVisitor(Visitor)
location: variable tour of type WhiteHouseTour
4 errors
What I have tried:
I have tried reading on this issue and fixing it myself but so far I haven't been successful. I also tried setting visitors in a different way but that hasn't worked for me either.