Help with this method - while loop
From: twistedheaven (twistedheaven_at_gmail.com)
Date: 11/28/04
- Next message: Pat: "GMail"
- Previous message: Andrew Thompson: "Re: Help with learning arrays"
- Next in thread: Chris Smith: "Re: Help with this method - while loop"
- Reply: Chris Smith: "Re: Help with this method - while loop"
- Reply: twistedheaven: "Re: Help with this method - while loop"
- Reply: Hal Rosser: "Re: Help with this method - while loop"
- Reply: twistedheaven: "Re: Help with this method - while loop"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 28 Nov 2004 13:30:02 -0500
Im having a few issues with my code, im using BlueJ, but i want to use a
while or for loop for the methods: startRentingHouse and stopRentingHouse.
But i dont have a good idea of how to go about it as i havent used them
before, can someone please point me in the right direction?
Many thanks
public class Landlord
{
private int numberOfHouses; //integer field for number of houses the
landlord may have
private int spendingMoney; //Money a landlord has to spend on houses
private House[] houses = new House[20]; //Array for the houses to
rent, the landlord can have a maximum of 20 homes
public Landlord()
{
numberOfHouses = 0;
spendingMoney = 1000000;
}
public Landlord(int savings)
{
numberOfHouses = 0;
spendingMoney = savings;
}
public int getMoney()
{
return spendingMoney;
}
public House[] getHouses()
{
return houses;
}
public int getNumberOfHouses()
{
return numberOfHouses;
}
public void purchaseHouse(House house)
{
if(spendingMoney >=house.getPurchasePrice() && numberOfHouses < 20) {
houses[numberOfHouses] = house;
numberOfHouses = numberOfHouses + 1;
spendingMoney = spendingMoney-house.getPurchasePrice ();
} else {
System.out.println("You are unable to buy anymore houses!");
}
}
/**
* Rent out a house. The given tennant is installed in the house whose
* address matches the given postcode and street number.
*
* @param postcode The postcode of the house
* @param number The street number
* @param tennant The new tennant of the house
*/
public void startRentingHouse(String postcode, int number, Tennant
tennant)
{
int rent = 0, number = 0;
while (int i=0; i <= houses; i++){
rent += [i];
}
return total;
}
}
/**
* Stop renting out a house. The tennant in the house with the
* given postcode and street number is set to null.
*
* @param postcode The postcode of the house
* @param number The street number
* @param tennant The new tennant of the house
*/
public void stopRentingHouse(String postcode, int number)
{
}
}
- Next message: Pat: "GMail"
- Previous message: Andrew Thompson: "Re: Help with learning arrays"
- Next in thread: Chris Smith: "Re: Help with this method - while loop"
- Reply: Chris Smith: "Re: Help with this method - while loop"
- Reply: twistedheaven: "Re: Help with this method - while loop"
- Reply: Hal Rosser: "Re: Help with this method - while loop"
- Reply: twistedheaven: "Re: Help with this method - while loop"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|