Skip to content

Commit c9b6c5d

Browse files
authored
Now we're playing!
-Fixed Setup -Starting to interpret user commands
1 parent bd26901 commit c9b6c5d

File tree

3 files changed

+225
-234
lines changed

3 files changed

+225
-234
lines changed

src/test/Line.java

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
1-
package test;
2-
3-
public class Line{
4-
5-
private int lNum;
6-
private String context;
7-
8-
public Line(int n, String info) {
9-
this.lNum=n;
10-
this.context=info;
11-
}
12-
13-
public int getLNum() {
14-
return lNum;
15-
}
16-
17-
public void setLNum(int n) {
18-
this.lNum = n;
19-
}
20-
21-
public String getContext() {
22-
return context;
23-
}
24-
25-
public void setContext(String c) {
26-
this.context = c;
27-
}
28-
29-
public String toString(){
30-
return "["+this.lNum+"] "+ this.context;
31-
}
32-
33-
public void print(){
34-
System.out.println(this.toString());
35-
}
36-
37-
}
1+
package test;
2+
3+
public class Line{
4+
5+
private int lNum;
6+
private String context;
7+
8+
public Line(int n, String info) {
9+
this.lNum=n;
10+
this.context=info;
11+
}
12+
13+
public int getLNum() {
14+
return lNum;
15+
}
16+
17+
public void setLNum(int n) {
18+
this.lNum = n;
19+
}
20+
21+
public String getContext() {
22+
return context;
23+
}
24+
25+
public void setContext(String c) {
26+
this.context = c;
27+
}
28+
29+
public String toString(){
30+
return this.lNum+") "+ this.context;
31+
}
32+
33+
public void print(){
34+
System.out.println(this.toString());
35+
}
36+
37+
}

src/test/LineItem.java

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
1-
package test;
2-
import util.Item;
3-
4-
/*
5-
* Wrapper Class to wrap around Line..
6-
* */
7-
8-
public class LineItem implements Item {
9-
10-
private Line line;
11-
12-
public LineItem(Line l) {
13-
this.line=l;
14-
}
15-
16-
public LineItem(int lNum, String context){
17-
this.line=new Line(lNum, context);
18-
}
19-
20-
/*
21-
* Overwritten - Implemented methods
22-
* - Only key should be the course code.
23-
* - By this rule we override methods.
24-
* */
25-
26-
@Override
27-
public boolean less(Item item) {
28-
29-
return line.getLNum() < (Integer)item.key();
30-
//return line.getLNum().compareTo(item.key().toString()) < 0;
31-
}
32-
33-
@Override
34-
public boolean equals(Item item) {
35-
return (this.line.getLNum() == (Integer)item.key());
36-
37-
}
38-
39-
@Override
40-
public Object key() {
41-
return this.line.getLNum();
42-
}
43-
44-
// a utility print function
45-
public void print(){
46-
this.line.print();
47-
}
48-
49-
@Override
50-
public Object getData() {
51-
return this.line;
52-
}
1+
package test;
2+
import util.Item;
3+
4+
/*
5+
* Wrapper Class to wrap around Line..
6+
* */
7+
8+
public class LineItem implements Item {
9+
10+
private Line line;
11+
12+
public LineItem(Line l) {
13+
this.line=l;
14+
}
15+
16+
public LineItem(int lNum, String context){
17+
this.line=new Line(lNum, context);
18+
}
19+
20+
/*
21+
* Overwritten - Implemented methods
22+
* - Only key should be the course code.
23+
* - By this rule we override methods.
24+
* */
25+
26+
@Override
27+
public boolean less(Item item) {
28+
29+
return line.getLNum() < (Integer)item.key();
30+
//return line.getLNum().compareTo(item.key().toString()) < 0;
31+
}
32+
33+
@Override
34+
public boolean equals(Item item) {
35+
return (this.line.getLNum() == (Integer)item.key());
36+
37+
}
38+
39+
@Override
40+
public Object key() {
41+
return this.line.getLNum();
42+
}
43+
44+
// a utility print function
45+
public void print(){
46+
this.line.print();
47+
}
48+
49+
@Override
50+
public Object getData() {
51+
return this.line;
52+
}
5353
}

0 commit comments

Comments
 (0)