forked from jcrouser/CSC120-A8
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCampusMap.java
More file actions
59 lines (49 loc) · 2.39 KB
/
CampusMap.java
File metadata and controls
59 lines (49 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import java.util.ArrayList;
public class CampusMap{
ArrayList<Building> buildings;
/* Default constructor, initializes empty ArrayList */
public CampusMap() {
buildings = new ArrayList<Building>();
}
/**
* Adds a Building to the map
* @param b the Building to add
*/
public void addBuilding(Building b) {
System.out.println("Adding building...");
buildings.add(b);
System.out.println("-->Successfully added " + b.getName() + " to the map.");
}
/**
* Removes a Building from the map
* @param b the Building to remove
* @return the removed Building
*/
public Building removeBuilding(Building b) {
System.out.println("Removing building...");
buildings.remove(b);
System.out.println("-->Successfully removed " + b.getName() + " to the map.");
return b;
}
public String toString() {
String mapString = "DIRECTORY of BUILDINGS";
for (int i = 0; i < this.buildings.size(); i ++) {
mapString += "\n " + (i+1) + ". "+ this.buildings.get(i).getName() + " (" + this.buildings.get(i).getAddress() + ")";
}
return mapString;
}
public static void main(String[] args) {
CampusMap myMap = new CampusMap();
myMap.addBuilding(new Library("Neilson Library", "7 Neilson Drive, Northampton, MA 01063", 5, true));
myMap.addBuilding(new Building("Campus Center", "Smith College Campus Center, 100 Elm St, Northampton, MA 01063", 3));
myMap.addBuilding(new Building("Ford Hall", "100 Green Street Northampton, MA 01063", 4));
myMap.addBuilding(new Building("Burton Hall", "46 College Ln, Northampton, MA 01063", 4));
myMap.addBuilding(new Building("Bass Hall", "4 Tyler Court Northampton, MA 01063", 4));
myMap.addBuilding(new Building("Schacht Center", "21 Belmont Ave, Northampton, MA 01060", 2));
myMap.addBuilding(new House("Lamont House", "17 Prospect Street, Northampton, MA 01063", 4, true, true));
myMap.addBuilding(new House("Cutter House", "1 Henshaw Ave, Northampton, MA 01063", 3, true, true));
myMap.addBuilding(new House("Comstock House", "1 Mandelle Rd, Northampton, MA 01063", 3, true, true));
myMap.addBuilding(new Cafe("Compass Cafe", "7 Neilson Drive, Northampton, MA 01063", 1, 100, 200, 200, 50));
System.out.println(myMap);
}
}