MCPcopy Create free account
hub / github.com/careercup/ctci / Box

Class Box

java/Chapter 9/Question9_10/Box.java:3–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1package Question9_10;
2
3public class Box {
4 public int width;
5 public int height;
6 public int depth;
7 public Box(int w, int h, int d) {
8 width = w;
9 height = h;
10 depth = d;
11 }
12
13 public boolean canBeUnder(Box b) {
14 if (width > b.width && height > b.height && depth > b.depth) {
15 return true;
16 }
17 return false;
18 }
19
20 public boolean canBeAbove(Box b) {
21 if (b == null) {
22 return true;
23 }
24 if (width < b.width && height < b.height && depth < b.depth) {
25 return true;
26 }
27 return false;
28 }
29
30 public String toString() {
31 return "Box(" + width + "," + height + "," + depth + ")";
32 }
33}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected