954,549 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

NEED HELP. Data storage problem.

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;
		}
		
}
willywhomperz
Newbie Poster
11 posts since Jul 2011
Reputation Points: 10
Solved Threads: 0
 
Having a lot of trouble with this


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

NormR1
Posting Expert
Moderator
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
 

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

willywhomperz
Newbie Poster
11 posts since Jul 2011
Reputation Points: 10
Solved Threads: 0
 

Start with item 1.

NormR1
Posting Expert
Moderator
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
 

Line 66 contains an error. the method is undefined.

also on line 75

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

willywhomperz
Newbie Poster
11 posts since Jul 2011
Reputation Points: 10
Solved Threads: 0
 

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.

NormR1
Posting Expert
Moderator
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
 

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

Majestics
Practically a Master Poster
621 posts since Jul 2007
Reputation Points: 199
Solved Threads: 49
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: