Help with this method - while loop

From: twistedheaven (twistedheaven_at_gmail.com)
Date: 11/28/04


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)
  {
           
  }

 }



Relevant Pages

  • Re: Help with this method - while loop
    ... > public int getNumberOfHouses() ... > * Rent out a house. ... > public void startRentingHouse(String postcode, int number, Tennant ...
    (comp.lang.java.help)
  • Re: Short address
    ... all you need here is your house number and postcode. ... because sometimes a postcode can cover more ... cul-de-sac in between 5 and 7, then all six houses in The Lane will ... Street from 2 upwards, ...
    (uk.finance)
  • Re: Short address
    ... have the same postcode and house number as a house in Main Street. ... A single postcode covers a set of adjacent premises in such a way ... back down the other side delivering the other. ...
    (uk.finance)
  • Re: Short address
    ... all you need here is your house number and postcode. ... because sometimes a postcode can cover more ... cul-de-sac in between 5 and 7, then all six houses in The Lane will ...
    (uk.finance)
  • Re: Short address
    ... So the house number isn't necesarily unique within a ... postcode - you do need the street name as well in order to be certain. ... identify a house uniquely. ... Cottage, 2 New Cottage all in the same road and post code. ...
    (uk.finance)