- public void removeHouse(String houseName) {
- this.dbMngr.removeHouse(houseName);
+ public void removeHouse(RuralHouse rh) {
+ this.dbMngr.removeHouse(rh);
}
// String description, String town, int nRooms, int nKitchens,
// int nBaths, int nLivings, int nParkings);
- public void removeHouse(String houseName);
+ public void removeHouse(RuralHouse rh);
/**
return stored;
}
- public void removeHouse(String houseName) {
+ public void removeHouse(RuralHouse rh) {
if (c.isDatabaseLocal() == false)
openSDB();
else
openDB();
- RuralHouse house = new RuralHouse(houseName, null, null, null, null);
try {
- ObjectSet<RuralHouse> result = db.queryByExample(house);
+ ObjectSet<RuralHouse> result = db.queryByExample(rh);
if (!result.isEmpty()) {
RuralHouse found = (RuralHouse) result.get(0);
db.delete(found);
public class Account {
-
-
- private String username="";
- private String password="";
+ private String username = "";
+ private String password = "";
private Owner owner;
-
- public Account (String usr, String pass, Owner ow){
+ private Administrator admin;
+
+ public Account(String usr, String pass, Administrator admin) {
this.username = usr;
- this.password= pass;
- this.owner= ow;
-
+ this.password = pass;
+ this.owner = null;
+ this.admin = admin;
+
+ }
+
+ public Account(String usr, String pass, Owner ow) {
+ this.username = usr;
+ this.password = pass;
+ this.owner = ow;
+ this.admin = null;
+
}
public String getUsername() {
public Owner getOwner() {
return owner;
}
-
-
+ public Administrator getAdmin() {
+ return admin;
+ }
+
+ public void setAdmin(Administrator admin) {
+ this.admin = admin;
+ }
+
}
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.util.Vector;
import javax.swing.JFrame;
import javax.swing.JPanel;
* Create the frame.
*/
public DeleteHouseGUI(Owner o) {
- o = owner;
+ this.owner = o;
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
+
+ comboBox = new JComboBox(this.owner.getRuralHouses());
-
- comboBox = new JComboBox();
-
JRadioButton rdbtnIAmSure = new JRadioButton("I am sure");
JButton btnDelete = new JButton("DELETE");
private void actionListenerButton(ActionEvent e){
RuralHouse toDel = (RuralHouse)comboBox.getSelectedItem();
HouseManagerInterface hm = new HouseManager();
- hm.removeHouse(toDel.getHouseName());
+ hm.removeHouse(toDel);
}
}
});
JButton btnDeleteHouses = new JButton("Delete Houses");
- btnDeleteHouses.setEnabled(false);
btnDeleteHouses.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Frame a = new DeleteHouseGUI(owner);