Error: The Type Property Already Defined
I'm having trouble running this program. Eclipse says "The type Propery is already defined."
Please help!
public class Assignment_2
{
public static void main(String[] args)
{
Property[] prop =
{
new Property('C', 100000, 3, 580,"1111 Ocean View, Ventura, CA"),
new Property('S', 300000, 6, 180, "10 Holly Oak, Littleton, CO"),
new Property('S', 500000, 5, 111, "28434 Agajanian Road, Santa Clari"
+ "ta, CA"),
new Property('S', 200000, 7, 200, "2 Lonesome Road, Albany, GA"),
new Property('R', 1650, 4, 500, "333 Candy Cane Lane, Redding, CA"),
};
Property.PrintArray("Properties:", prop);
Property.ArraySort(prop, "byPrice");
Property.PrintArray("Properties Sorted by Price:", prop);
Property.ArraySort(prop, "byNumRooms");
Property.PrintArray("Properties Sorted by Number of Rooms:", prop);
Property.ArraySort(prop, "byDaysOnMarket");
Property.PrintArray("Properties Sorted By Number of Days on Market:"
, prop);
}
}
class Property
{
private char type;
private int price;
private int bedrooms;
private int days_on_market;
private String address;
public final static int MIN_LENGTH = 1;
public final static int MAX_LENGTH = 100;
public final static int MIN_PRICE = 0;
public final static int MAX_PRICE = 100000000;
public final static int MIN_BEDS = 1;
public final static int MAX_BEDS = 20;
public final static int MIN_DAYS = 0;
public final static int MAX_DAYS = 365*5;
public final static char DEFAULT_TYPE = 'R';
public final static int DEFAULT_PRICE = 0;
public final static int DEFAULT_BEDROOMS = 1;
public final static int DEFAULT_DAYS = 0;
public final static String DEFAULT_ADDRESS = " unknown ";
public final static String PRICE = "byPrice";
public final static String ROOMS = "byNumRooms";
public final static String DAYS = "byDaysOnMarket";
public Property(char typ, int cost, int beds, int days, String location)
{
type = DEFAULT_TYPE;
price = DEFAULT_PRICE;
bedrooms = DEFAULT_BEDROOMS;
days_on_market = DEFAULT_DAYS;
address = DEFAULT_ADDRESS;
if (typ == 'R' || typ == 'C' || typ == 'S')
type = typ;
if (cost >= MIN_PRICE && cost <= MAX_PRICE)
price = cost;
if (beds >= MIN_BEDS && beds <= MAX_BEDS)
bedrooms = beds;
if (days >= MIN_DAYS && days <= MAX_DAYS)
days_on_market = days;
if (location.length() > MIN_LENGTH && location.length() <= MAX_LENGTH)
address = location;
}
public static void ArraySort(Property property_list[], String key_field)
{
for (int k = 0; k < property_list.length; k++)
{
if (key_field == PRICE && !LargestPriceToTop(property_list,
property_list.length-1-k))
return;
else if (key_field == ROOMS && !LargestNumRoomsToTop(
property_list, property_list.length-1-k))
return;
else if (key_field == DAYS && !LongestToTop(property_list,
property_list.length-1-k))
return;
else
return;
}
}
public static void PrintArray(String title, Property property_list[])
{
System.out.println("\n********** " + title + " **********\n");
for (int k = 0; k < property_list.length; k++)
System.out.println(property_list[k].Listing());
System.out.println();
}
private static boolean LargestPriceToTop(Property[] property_list, int top)
{
boolean changed = false;
Property propty;
for (int k = 0; k < top; k++)
if (property_list[k].price < property_list[k+1].price)
{
propty = property_list[k];
property_list[k] = property_list[k+1];
property_list[k+1] = propty;
changed = true;
}
return changed;
}
private static boolean LargestNumRoomsToTop(Property[] property_list,
int top)
{
boolean changed = false;
Property propty;
for (int k = 0; k < top; k++)
if (property_list[k].bedrooms < property_list[k+1].bedrooms)
{
propty = property_list[k];
property_list[k] = property_list[k+1];
property_list[k+1] = propty;
changed = true;
}
return changed;
}
private static boolean LongestToTop(Property[] property_list, int top)
{
boolean changed = false;
Property propty;
for (int k = 0; k < top; k++)
if (property_list[k].days_on_market <
property_list[k+1].days_on_market)
{
propty = property_list[k];
property_list[k] = property_list[k+1];
property_list[k+1] = propty;
changed = true;
}
return changed;
}
public String ConvertType()
{
String return_string = null;
if (type == 'R')
return_string = "Rental";
if (type == 'C')
return_string = "Condo";
if (type == 'S')
return_string = "Single Family Dwelling";
return return_string;
}
public String Listing()
{
String ret_string;
ret_string = "Type: " + ConvertType() + ", Price: $" + price + ", " +
"Days on Market: " + days_on_market + ", Bedrooms: " + bedrooms + ", "
+ address;
return ret_string;
}
}