【发布时间】:2014-12-15 13:42:23
【问题描述】:
试图简化我的程序我正在尝试创建这个测试器来测试我的其他类的添加和删除方法并打印数组列表中的属性列表我被困在如何继续
请帮忙
public class Tester
{
public static void main (String[] args)
{
}
public Tester ()
{
Apartment testingApartment = new Apartment();
Basement testingBasement = new Basement();
Company testingCompany = new Company();// Contains list of
// properties to sell
// in arraylist
// elements with a 2 after the name are used for the Basement
// elements
String Apartmentneighbourhood = "Parkdale";
String Basementneighbourhood = "Rexdale";
double price = 400000.99;
double price2 = 5000000.99;
int numberofbaths = 3;
int numberofbaths2 = 5;
int numberofbedrooms = 2;
int numberofbedrooms2 = 4;
int squarefoot = 3000;
int squarefoot2 = 5000;
int floors = 4;
int floorlevel = 4;
testingApartment.setneighbourhood(apartmentneighbourhood);
testingBasement.setneighbourhood(Basementneighbourhood);
testingApartment.setprice(price);
testingBasement.setprice(price2);
testingApartment.setbathNum(numberofbaths);
testingBasement.setbathNum(numberofbaths2);
testingApartment.setbedNum(numberofbedrooms);
testingBasement.setbedNum(numberofbedrooms2);
testingApartment.setsqrft(squarefoot);
testingBasement.setsqrft(squarefoot2);
testingApartment.setNumFloors(floors);
testingBasement.setFloorLevel(floorlevel);
}
}
这是我的 Apartment Class 中的 add 方法
public void addApartment(Apartment newApartment)
{
Apartment ApartmentInput = new Apartment();
ApartmentInput = newApartment;
Arraylist.add(ApartmentInput);
}
【问题讨论】:
-
我认为你的代码还没有编译,我在看main方法,它看起来还没有完成,你能编辑一下吗?
-
好多了,谢谢,给我几分钟,我有事给你,我现在有点忙
-
你能发布一个可编译的代码吗?
-
我正在尝试修复代码我不确定为什么代码无法编译我正在尝试修复它,我会在发现问题后立即发布。
-
那没关系,我想他们抓住了你
标签: java arrays inheritance arraylist casting