Question
Use Building class : public class Building2 { private String name; private String address; private int numFloors; private
Use "Building" class : public class Building2 {
private String name;
private String address;
private int numFloors;
private int buildingID;
//Default constructor
public Building2(){
name = "Default Building";
address = "Default Address";
numFloors = 0;
buildingID = 0;
}
// Constructor with argument
public Building2(String name, String address , int numFloors, int buildingID) {
this.name = name;
this.address = address;
this.numFloors = numFloors;
this.buildingID = buildingID;
}
// Setter and getter methods
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setAddress(String address) {
this.address = address;
}
public String getAddress() {
return address;
}
public void setNumFloors(int floors) {
this.numFloors = floors;
}
public int getNumFloors() {
return numFloors;
}
public int getBuildingID() {
return buildingID;
}
public void setBuildingID(int buildingID) {
this.buildingID = buildingID;
}
@Override
public String toString() {
return "Name: " + name +
"Address: " + address +
"Floors: " + numFloors +
"Building ID: " + buildingID;
}
}
and the array : import java.util.ArrayList;
public class Array {
public static void main(String[] args) {
ArrayList
Building1.add(new Building2("Building A", "123 Main Street", 5, 1));
ArrayList
Building2.add(new Building2("Building B", "456 Elm Street", 10, 2));
ArrayList
Building3.add(new Building2("Building C", "789 Oak Street", 7, 3));
@SuppressWarnings("unchecked")
ArrayList
BuildingsArray[0] = Building1;
BuildingsArray[1] = Building2;
BuildingsArray[2] = Building3;
for (ArrayList
for (Building2 building1 : buildings) {
System.out.println("Building Name: " + building1.getName());
System.out.println("Address: " + building1.getAddress() );
System.out.println("Number of Floors: " + building1.getNumFloors());
System.out.println("Building ID: " + building1.getBuildingID());
System.out.println();
}
Create a GUI for a "Building Manager" application. Present a GUI List of Buildings from the Array in #2
Add Building / Delete Building buttons or menu items. You should have text fields to enter information for a new building. You should update your Array from #2 as you add and delete items.
Update a "pane" or "canvas" with a drawing of that building (it doesn't have to be "beautiful" since we aren't an Art class) using shapes (reference how you drew the "Car" from one of your Extra Credit Labs) (hint: make a few different draw methods - drawBuilding1(), drawBuilding2(),... and call the appropriate one as they select it from the list as the current one)
Have a "SEARCH" feature for your Building Manager which will show the characteristics of the building if it is found. You can make this a button or a menu item. You must use the RECURSIVE binary search algorithm which takes a sorted list of ints and look for a number in that list (hint: put the building ids into a sorted list and then use that to search for a building id. If the building id is found, show the characteristics of the building (use a label or text field) and if the building id is not found, use the label to indicate that it wasn't found).
Implement a "SAVE" feature. Create a database table called Buildings & save your building information to it after user clicks on a "Save" button or a save menu item.
Step by Step Solution
3.38 Rating (160 Votes )
There are 3 Steps involved in it
Step: 1
import javaxswing import javaawt import javaawtevent import javautilArrayList import javautilCollections public class BuildingManagerApp extends JFrame private DefaultListModel buildingListModel priva...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started