Click here to Skip to main content
14,211,379 members
Rate this:
Please Sign up or sign in to vote.
See more:
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);
        
        //System.out.println(tour);
    }
}


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.
Posted
Updated 4-Jun-17 21:29pm

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

The message is telling you what line the error occurs on, and what the problem is. Go to line 20 and look at the statement; where is the definition of WhiteHouseTour?

Your time would be better spent working through the Java Tutorials, which Google will find for you.
   
Comments
CPallini 5-Jun-17 5:03am
   
5.
dc_14 5-Jun-17 9:27am
   
You can just tell me that you don't know how to fix it buddy but thanks for your comment.
Richard MacCutchan 5-Jun-17 9:35am
   
Of course I know how to fix it. You create a proper WhiteHouseTour class and import its definition into your program. Like I said, go and work through the Java Tutorials and learn the basics of Java programming.
dc_14 5-Jun-17 10:33am
   
I'm learning this in school right now and I don't want to learn new techniques, at least not yet. Once I feel more comfortable with Java then I will teach myself new topics.
Richard MacCutchan 5-Jun-17 11:27am
   
Then maybe you should talk to your teacher rather than posting questions here.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Cookies | Terms of Service
Web01 | 2.8.190619.1 | Last Updated 5 Jun 2017
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100