i know i need to post properly using (code) (block codes),, this is my understanding of that rule if i'm wrong pls teach me, i will abide. thank you
I have been trying to get this code right for 4 days, i am losing hope. i know you'll understand me. Thank you very much

import java.util.*;
class Property
{
   private String ID;
   private String location;
   private String description;
   private double weekllRentalRate;

   public Property(String pID, String ploc, String pdesc, double weelyR)
   {
       ID = pID;                                      /* constructor */
       ploc = location;
       pdesc = description;
       weeklyRentalRate = double weelyR;
   }
   public String getID()
   {
       return ID;
   }
   public String getDescription ()
   {
      return description;
   }
   public String getLocation()
   {
       return location;
   }
   public double getweeklyRate()
  {
       return weeklyRetalRate;
  }

  public void addProperty(String pID, String ploc, String pdesc, double weelyR)
  {
     Scanner scan = new Scanner(System.in);
     System.out.println("Enter ID");                    // addProperty method
     String ID = scan.nextLine();                       //   I'm trying to make it work
     System.out.println("Enter Location");              //   on the other class , 
     String location = scan.nextLine();                 //  main method     
     System.out.println("Enter Description");
     String description = scan.nextLine();
     System.out.println("Enter Description");
     double weelyRentalRate =  scan.nextDouble();

       new Property("ID", "location", "description", 0.0)
  }




public class Administration
{
   public Static void main(String [] args)
{
   Scanner scan = new Scanner(System.in);

   Property[] properties = new Property[10];
   int count = 0;
    Property properties[count] = new Property("AP001", "2-bedroom apartment",  
                                             "Doclands", 550);
    count++;
    Property properties[count] = new Property("UN112", "3-bedroom unit", "Seddon", 
                                               465);
    count++
     Property properties[count] = new Property("ED030", "renovated Edwardian",  
                                               "Camberwell", 650);
      count++

     int num;
     num = scan.nextInt()

     if (num == 1)
        properties .addProperty()    // i've tried parameters but i can't get it right 
      else if (num == 2)
               properties .startRental()
   }

I don't know what value/parameter to pass on the methods from Property class to Admin class vice versa is it Array or Objects. I'm really drained.
little guidance would be really appreciated.
thank you in advance.
John
melbourne,Aus

i know i need to post properly using [code] (block codes)

If you know that, why post code without them?
Why don't you edit your post and add them.

what value/parameter to pass on the methods from Property class to Admin class

Could you add comments to your code showing exactly where you are having the problem?

Something like: //************ HERE I'M CONFUSED ON HOW TO .....

It would be easier to help if you were to tell us exactly what you're trying to do.

Even if you think your naming conventions are clear, you might be surprised. "Property", for example, is more likely to make a developer think of "attribute of an object" than "flat to be rented". Took me a second look to figure out what the point of the program was.

I see you're having trouble parsing the rental income (so you're underpricing your apartments significantly :) ). Try scanning it as a string (nextLine) and then using Double.parseDouble() to get the number. Wrapping that in a try block will help, since users are good at giving you bad input.

Okay, if I'm reading this right you're trying to use the addProperty() method of the array properties. The array doesn't have that method, though - it's an array, not a Property.

Does that help?

import java.util.*;
class Property
{
private String ID;
private String location;
private String description;
private double weekllRentalRate;

public Property(String pID, String ploc, String pdesc, double weelyR)
{
ID = pID;                         /* constructor */
ploc = location;
pdesc = description;
weeklyRentalRate = double weelyR;
}
public String getID()
{
return ID;
}
public String getDescription ()
{
return description;
}
public String getLocation()
{
return location;
}
public double getweeklyRate()
{
return weeklyRetalRate;
}

public void addProperty(String pID, String ploc, String pdesc, double weelyR)
{
Scanner scan = new Scanner(System.in);
System.out.println("Enter ID");                                  // addProperty method
String ID = scan.nextLine();                                     // I'm trying to make it work
System.out.println("Enter Location");                            // on the other class ,
String location = scan.nextLine();                               // main method
System.out.println("Enter Description");
String description = scan.nextLine();
System.out.println("Enter Description");
double weelyRentalRate = scan.nextDouble();

new Property("ID", "location", "description", 0.0)
}




public class Administration
{
public Static void main(String [] args)
{
Scanner scan = new Scanner(System.in);

Property[] properties = new Property[10];
int count = 0;
Property properties[count] = new Property("AP001", "2-bedroom apartment",
"Doclands", 550);
count++;
Property properties[count] = new Property("UN112", "3-bedroom unit", "Seddon",
465);
count++
Property properties[count] = new Property("ED030", "renovated Edwardian",
"Camberwell", 650);
count++

int num;
num = scan.nextInt()

if (num == 1)
properties .addProperty()                 // i've tried parameters but i can't get it right
                                           // very confused here tried (Property[] properties)  
                                          //very confused here tried ("ID", "location", 
                                                                     "description", 0.0)
                                          // trying to put more properties on Array Property
else if (num == 2)                        
properties .startRental()   
}

Are you still having problems?

i think i got the wrap codes part right..

hi NormR1
GoodDay mate!
still tring mate

i'm trying to add to an Array
using addProprty method

Okay, let me expand on my hint above. An array is simply a collection of objects or primitives. It has none of the properties of the objects it contains - particularly, it doesn't have access to their methods or fields. "Property" has a method, addProperty(), which essentially constructs a property. the array properties[] does not have access to that, and if it did, it wouldn't know what to do with it.

If you're trying to make an object which consists of a collection of Property objects, one way to do it would be to make a class Properties which contains an array (or an ArrayList - ArrayLists are cool) of Property objects. Then you can give Properties an addProperty(Property p) method which will turn around and add p to your array or arraylist. Or, if you want to keep the array out in the open, as you have it now, you'll have to do something like properties[properties.length] = p, where p is the property you're adding. You might sub that out to a method, and call it addProperties(), but that would be a method of your Administration class, not of the array properties.

But what you can't do is just tell an array to addProperty() - it doesn't know what you mean, and there's no way to tell it. This is a little like trying to do this:

int[] array1 = {1,2,3};
int[] array2 = {4,5,6);
System.out.println( array1+array2);

Does that make sense?

As jon.kiparsky says, arrays do NOT have an addProperty() method.
The way to put a value into an array is by using an index to select the element where you want the value saved:

int[] anArray = new int[12];
  anArray[9] = 22;  // set the 10th element of this array to the value 22

That "adds" a value of 22 to the array. The 9 in the above is the index into the array.

Thanks john kiparsky,,
i appreciate your help mate
i'm giving up,, i'm out of time and neglecting my wife and kidds
i'll study something else(i'm good at)
by the way this site is good it teaches and helps without spoonfeeding.
more power bro!

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.