-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCookieJarRunner.java
More file actions
26 lines (21 loc) · 964 Bytes
/
CookieJarRunner.java
File metadata and controls
26 lines (21 loc) · 964 Bytes
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
//(c) A+ Computer Science
//www.apluscompsci.com
//Name - Patrick Dobranowski
public class CookieJarRunner {
public static void main(String[] args) {
CookieJarDobranowski c = new CookieJarDobranowski(3000); // sets capacity to 3000
System.out.println(c.isFull()); // cookiejar is not full
c.addStuff(500); // add 500 items
System.out.println(c.isFull()); // cookiejar is not full
System.out.println(c.addStuff(2000)); // add 2000 items and return -500
// -500 indicates 500 items can be added
System.out.println(c.spaceLeft()); // space left is 500
System.out.println(c.isFull()); // cookiejar is not full
System.out.println(c.addStuff(2000)); // attempt to add 2000
// adds 500 and returns 1500
// 1500 was amount left
// that could not be added
System.out.println(c.spaceLeft()); // no space left � returns 0
System.out.println(c.isFull()); // returns true
}
}