calling from another classwhy isn't oneSite not applied to int

J

Jucy Love

this is the first file called EventSite3.java
public class EventSite3
{
private int siteNumber;
public int getSiteNumber()
{
return siteNumber;
}
public void setSiteNumber(int n)
{
siteNumber = n;
}
}

this is the second file called SetUpSite5.java
public class SetUpSite5
{
int currentYear = 2003;
int age;
EventSite3 oneSite = new EventSite3();
int number;


public void statementOfPhilosophy()
{
age = calculateAge(currentYear);
number = oneSite.getSiteNumber();
oneSite.getSiteNumber(9);
System.out.println("Serving you " + age + " years");
System.out.println("The number of the event site is " + number);
System.out.println("Event Handlers Incorporated is");
System.out.println("dedicated to making your event");
System.out.println("a most memorable one.");
}
public static int calculateAge(int currDate)
{
int yrs;
yrs = currDate - 1977;
return yrs;
}
}
 
J

Joseph Millar

number = oneSite.getSiteNumber();
oneSite.getSiteNumber(9);

Guess I don't understand this. Here you are getting the
site number before it has ever been set, then you are
making an invalid call, getSiteNumber() does not take an
int as a parameter, it only returns an int as in the
previous call. The above code will not even compile
as written.

--Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top