Trying to get this code to work (bit of guidance and help would make a difference)
explanations only are fine..
main method doesn't accept arrayProperty()

import java.util.*;
class Property 
{
   private String ID;
   private String description;
   private String location;
   private double weeklyRR;
   private char status ;
   private boolean visibility;

   public Property (String pID, String pDesc, String pLOc, double weeklyR )                
   {
      ID = pID;
      description = pDesc;
      location = pLOc;
      weeklyRR = weeklyR;   
      status = 'A';
      visibility = false;
   } 

   public String getID()            { return ID; }
   public String getDescription()   { return description; }
   public String getLocation()      { return location; }
   public double getWeeklyRR()      { return weeklyRR; }
   public char getStatus()          { return status; }
   public boolean getVisibility()   { return visibility; } 


   public void addProperty(String pID, String pDesc, String pLOc,double weeklyR)
   {  
      Scanner scan = new Scanner(System.in);
      Property properties[];
      properties = new  Property[10];     
      int count = 6;

      System.out.println("Enter ID");
      String ID = scan.nextLine();
      System.out.println("Enter Description");
      String description = scan.nextLine();
      System.out.println("Enter Location");
      String location = scan.nextLine();
      System.out.println("Enter weekly rental rate");
      double weeklyRR = scan.nextDouble();    
      properties[count]=new Property(ID,  description, location, weeklyRR); 
      count++;        
   }



   public boolean startRental (String tenantID, GregorianCalendar startDate)
   {

       return true;
   }

   public double terminateRental (GregorianCalendar endDate)
   {
       double charges = weeklyRR ;
       return charges;     
   }  

   public void printPropertyDetails()
   {

   } 
}


import java.util.*;
public class Administration 
{
     public static void Menu()
     {
         System.out.println("Menu");
         System.out.println("1. Add Properties to the system");
         System.out.println("2. Enter Rental Agreement information (provide: prop ID, tenant ID, start Date)");
         System.out.println("3. Terminate a Rental agreement (provide: prop ID, tenant ID, End Date)");
         System.out.println("4. Search for Properties(based on weekly_rental_rate)");
         System.out.println("5. List Properties(not visible to clients)");
         System.out.println("6. List Properties (currently rented out)");
         System.out.println("7. List Properties(available for rent)");
         System.out.println("8. Display the details(1 property or all)");
         System.out.println("9. Exit");      
     }  

    public static int getAnswer()
   {
      int answer;
      Scanner scan = new Scanner(System.in);
      answer = scan.nextInt();

      while ( answer < 1 || answer > 9 )
      {
         if ( answer  ==  9 )
            return answer;

         System.out.println("Invalid entry Try again") ;
         answer = scan.nextInt();           
      }
     return answer; 
    }


      public static void arrayProperty(String pID, String pDesc, String pLOc,double weeklyR)
       {
           Property properties[];
           properties = new  Property[10];    
           int count = 0;

           properties[count] = new Property("AP001", "2-bedroom apartment with city views", "Docklands", 550);  
              count++;
              properties[count] = new Property("UN112", "modern 3-bedroom unit", "Seddon", 465);
              count++;
              properties[count] = new Property("AP002", "older style 1-bedroom flat with gas cooking", "South Yarra", 310);
              count++;
              properties[count] = new Property("ED030", "renovated Edwardian with 4 bedrooms", "Camberwell", 650);
              count++;
              properties[count] = new Property("ED034", "original Edwardian with large backyard", "Moonee Ponds", 475);         
              count++;
              properties[count] = new Property("VT001", "single-fronted Victorian Terrace with 2 bedrooms and small courtyard"
                                            , "Brunswick", 465);                  
              count++;

              properties[count].addProperty(pID, pDesc, pLOc, weeklyR);
              count++;         
       }       


    public static void main(String[] args)
   {  
       int num;
       Scanner scan = new Scanner(System.in);

       Menu();       
       num = getAnswer();                 

      while(num != 9)
       {
          if ( num == 1)
            [B][COLOR="Red"]arrayProperty();[/COLOR][/B]


          Menu();      
          num = getAnswer();

       }
      System.out.println("Exit");
     }  
}

please disregard this i just answered it thanx

arrayProperty(scan.nextLine(),scan.nextLine(),scan.nextLine(),scan.nextDouble());

但是我试验的结果是nullpointer的错误,所以我觉得是不是这两个类没有写完全!!
请高手指教!!

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.