YOMEDIA
Inheritance Review_Object-oriented programming
Chia sẻ: Nguyen Phong
| Ngày:
| Loại File: PPT
| Số trang:6
78
lượt xem
4
download
Download
Vui lòng tải xuống để xem tài liệu đầy đủ
Inheritance Review
Object-oriented programming
.Expressions
Numeral - int: value + Numeral(int) + Numeral()
"interface" Expression
+ asString(): String + evaluate(): int
Square - Expression: expression + Square(Expression)
"interface"
AMBIENT/
Chủ đề:
Nội dung Text: Inheritance Review_Object-oriented programming
- Inheritance -
Review
Object-oriented programming
- Expressions "interface"
Expression
+ asString(): String
+ evaluate(): int
Numeral
- int: value
+ Numeral(int) "interface"
+ Numeral() BinaryExpression
Square
- Expression: expression
+ Square(Expression)
+ left(): Expression
+ right(): Expression
Addition
- Expression: left
- Expression: right
+ Addition(Expression, Expression)
Inheritance 2
- Generic Stack
class MyStack {
...
public void push(Object obj) {...}
public Object pop() {...}
} ...
MyStack s = new MyStack();
Point p = new Point();
Circle c = new Circle();
s.push(p);
s.push(c);
Circle c1 = (Circle) s.pop();
Point p1 = (Point) s.pop();
Inheritance 3
- Node start
Generic List + data: Object
+ next: Node
+ Node(Object, Node)
MyList
- Node: start end
- Node: end
+ MyList ()
+ append(Object)
MyList l = new MyList(); + appendList(MyList)
l.append(1); + toString(): String
l.append(2);
System.out.println(l); // (1, 2)
MyList l2 = new MyList();
l2.append(3);
l2.append(4);
System.out.println(l2); // (3, 4)
l.append(l2);
System.out.println(l); // (1, 2, (3, 4))
l.appendList(l2);
System.out.println(l); // (1, 2, (3, 4), 3, 4)
l2.append(5);
System.out.println(l); // (1, 2, (3, 4, 5), 3, 4)
Inheritance 4
- Generic List
Problem!!!
l.append(l)
Inheritance 5
- Better List
Node
+ data: Item
+ next: Node
+ Node(Item, Node) "Interface"
Item
+ clone(): Item
+ toString(): String
MyList
- Node: start
- Node: end
NumeralItem StringItem
+ MyList ()
+ append(Item) - int: value - String: value
+ appendList(MyList) + NumeralItem(int) + StringItem(int)
Inheritance 6
Thêm tài liệu vào bộ sưu tập có sẵn:
Báo xấu
LAVA
ERROR:connection to 10.20.1.100:9315 failed (errno=111, msg=Connection refused)
ERROR:connection to 10.20.1.100:9315 failed (errno=111, msg=Connection refused)
Đang xử lý...