I've been trying to understand how to call a method from inside another method of the same class by reading "Java how to program early objects".
I'm totally lost at the moment, the analogy used in the book makes it easy to visualise whats going on. However, translating that into code is challenging.
I have tried many times to figure this out and have gotten this far: P.S. for the sake of simplicity I have excluded code that I think is not important for my question...
import java.util.Scanner;
public class BuyAHouseInc
{
private int housePrice;
private int amountOfHouses;
private int houseCounter;
// method to enter the amount of houses on sale
public void setAmountOfHouses()
{
// do stuff etc.
}
// method that sets the house price
public void setHousePrice()
{
// do stuff etc.
calculateFees(this.housePrice); // this is where I'm not sure...
}
//method to calculate fees and taxes
public void calculateFees(int housePrice) // does this receive this.housePrice?
{
// do some stuff
}
Tester code:
public class BuyAHouseIncTester
{
public static void main(String[] args)
{
BuyAHouseInc client1 = new BuyAHouseInc("John","Doyle","15 Newton Drive\nDublin 5\n", 550000) // Create object
// set amount of houses on sale to client 1
client1.setAmountOfHouses();
// set house price for each of the houses added to database
client1.setHousePrice();
}
}
What is the code to call a method inside another method? Do the values of each individual house price get called?