-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComputerStore.java
More file actions
35 lines (31 loc) · 1.04 KB
/
ComputerStore.java
File metadata and controls
35 lines (31 loc) · 1.04 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
//Program 4 created by James Bellamy, due Oct 30, 2018
//This program creats a ComputerStore class to host array of
//Computer objects.
public class ComputerStore {
private Computer[] systems;
private int sysNumbers;
//creates ComputerStore constructor, to construct array of ComputerStore objects
public ComputerStore() {
systems = new Computer[200];
sysNumbers = 0;
}
//add method to add an object to the array.
public void add(String c, int r, String g, String m, String p, double co, int sn, double d) {
systems[sysNumbers++] = new Computer(c, r, g, m, p, co, sn, d);
}
//toString method
public String toString() {
String result = "";
for (int i = 0; i < sysNumbers; i++)
result += systems[i].toString() + "\n";
return result;
}
//find system method, will return motherboard given cpu input.
public String findSys(String c) {
for (int i = 0; i < sysNumbers; i++) {
if (systems[i] != null && systems[i].getCpu().equals(c))
return systems[i].getMotherboard();
}
return null;
}
}