对不起,我是Java新手,可能有一个非常简单的答案。使用Get和Set时可以应用搜索功能吗?
目前,我将所有结果打印在个人JOptionPane
s中。
我想建立一个搜索功能让我能够根据给定的标准显示某些结果。
这里是我到目前为止的代码:
public class Main {
public static void main(String[] args) {
//Create new Person objects
Address p1 = new Address("27","Abbey View","Hexham","NE46 1EQ");
Address p2 = new Address("15", "Chirdon Crescent", "Hexham", "NE46 1LE");
Address p3 = new Address("6", "Causey Brae", "Hexham", "NE46 1DB");
Details c1 = new Details();
Details c2 = new Details();
Details c3 = new Details();
//Send some messages to the objects
c1.setBeds("3 ");
c2.setBeds("6");
c3.setBeds("4");
c1.setPrice("175,000");
c2.setPrice("300,00");
c3.setPrice("250,000");
c1.setType("Terraced");
c2.setType("Bungalow");
c3.setType("Detached");
//Set up the association
p1.ownsDetails(c1);
p2.ownsDetails(c2);
p3.ownsDetails(c3);
//Print result
p1.printDetails();
p2.printDetails();
p3.printDetails();
//Finally quit
System.exit(0);
}
}
任何帮助,将不胜感激,谢谢。
这使得更多的意义,感谢您的快速响应:) – 2011-04-16 13:35:34