-
Notifications
You must be signed in to change notification settings - Fork 0
/
java-patt.1.java
88 lines (74 loc) · 1.71 KB
/
java-patt.1.java
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// -*- mode: java; buffer-read-only: t -*-
abstract class SeasoningD {}
class Salt extends SeasoningD {}
class Pepper extends SeasoningD {}
class Thyme extends SeasoningD {}
class Sage extends SeasoningD {}
abstract class PointD {}
class CartesianPt extends PointD {
int x;
int y;
CartesianPt(int _x, int _y) {
x = _x;
y = _y;
}
// ----------------------------------------
}
class ManhattanPt extends PointD {
int x;
int y;
ManhattanPt(int _x, int _y) {
x = _x;
y = _y;
}
// ----------------------------------------
}
abstract class NumD {}
class Zero extends NumD {}
class OneMoreThan extends NumD {
NumD predecessor;
OneMoreThan (NumD _p) {
predecessor = _p;
}
// ----------------------------------------
}
abstract class LayerD {}
class Base extends LayerD {
Object o;
Base (Object _o) {
o = _o;
}
// ----------------------------------------
}
class Slice extends LayerD {
LayerD l;
Slice (LayerD _l) {
l = _l;
}
// ----------------------------------------
}
class Test {
private static void test1() {
Salt s = new Salt();
Pepper p = new Pepper();
Thyme t = new Thyme();
Sage s0 = new Sage();
}
private static void test2() {
NumD z = new Zero();
NumD one = new OneMoreThan(z);
NumD two = new OneMoreThan(one);
System.out.println(z);
System.out.println(one);
System.out.println(two);
}
private static void test3() {
new Base(new Zero());
new Base(new Salt());
}
public static void main(String[] args) {
test1();
test2();
test3();
}
}