I am trying to do several things.
1. Intialize - engage a user in a series of questions to assign values to the class variables, no args, no return value, called from constructor.
2. Display - displays all the class values, each in an sentence, no args, no return value.
3. getId - returns the id of the Property to the caller, no args, 1 return value, the id of this property. (needed in the "find" method of the class RealEstate.
4. calcTaxrate - calculates a tax rate, based on the values of the variables. It is not necessary to put any code into the body of this method.

Having a lot of trouble with this and appreciate any help.

import java.util.*;

public class RealEstate 
{

	private static Property[]database = new Property[64];
	private static int propertyCount = 0;
	
	class Property
	{
		private int id; //assigned by the program. It starts with 1.

		
			private String address; //A single string, any contents

		
				private int numberStories; // no half-stories

		
					private int age; //in years

		
						private int purpose; //residential, commercial

							private boolean multiple; //true = multiple family, false = single family

		
								private boolean externalWater; // true = outside water faucet exists
		
		
									private int porchSize; // square feet. 0 = no porch

		
										private int yardSize; //square feet. 0 = no yard.
	}
	
	
		public static void main(String[]args)
		{
			Scanner in = new Scanner(System.in);
			Property address;
			
			System.out.println("BigMarket Real Estate Inc.");
			System.out.println("");
			boolean finished = false;
				while(finished ==false)
				{
					System.out.println("What would you like to do?");
					System.out.println("Please type N for 'Enter New Property'");
					System.out.println("D for 'Display Existing Propery'");
					System.out.println("Q for 'Quit the Program;");
					String answer = in.next();
					
						if (answer.equals("Q") || answer.equals("q"))
						{
							System.out.println("Program terminating. Thank You!");
							finished=true;
						}
							if(answer.equals("D")||answer.equals("d"));
							{
								System.out.println("Which property will you display?");
								int where = in.nextInt();
								address = find(where);
								if(address !=null)
								{
									address.display();
								}
								else
								{
									System.out.println("Sorry.Sorry! Can't find that one.");
								}
							}
							if(answer.equals("N")||answer.equals("n"));
							{
								database[propertyCount] = new Property(propertyCount+1);
								propertyCount+=1;
							}
				}
		}
		
		private static Property find(int Id)
		{
			Property home = null;
			for (int index = 0; index < propertyCount; index +=1)
			{
				if(database[index].getId() == Id)
				{
					home = database[index];
					return home;
				}
			}
			return home;
		}
		
}

Recommended Answers

All 6 Replies

Having a lot of trouble with this

Please list your troubles item by item as per your list.

not too sure where to start. I am using Eclipse.

Start with item 1.

Line 66 contains an error. the method is undefined.

also on line 75

and 86. I don't know how to solve these errors.

What method is used on line 66?
Where is it defined?
Why did you code the usage of that method?
If you have no use for that method, then Comment out that line so the code will compile.

Same for line 75 and 86.

Create Method Display in property Class
Property dont have constructor to take parameter
Create Method getId in property Class

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.