Đang chuẩn bị liên kết để tải về tài liệu:
Inheritance Review_Object-oriented programming

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

Inheritance Review Object-oriented programming .Expressions Numeral - int: value + Numeral(int) + Numeral() "interface" Expression + asString(): String + evaluate(): int Square - Expression: expression + Square(Expression) "interface" | Inheritance - Review Object-oriented programming Expressions Inheritance "interface" Expression + asString(): String + evaluate(): int "interface" BinaryExpression + left(): Expression + right(): Expression Numeral - int: value + Numeral(int) + Numeral() Square - Expression: expression + Square(Expression) Addition - Expression: left - Expression: right + Addition(Expression, Expression) Inheritance Generic Stack . 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(); class MyStack { . public void push(Object obj) {.} public Object pop() {.} } Generic List Inheritance MyList l = new MyList(); l.append(1); 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) Node + data: Object + next: Node + Node(Object, Node) MyList - Node: start - Node: end + MyList () + append(Object) + appendList(MyList) + toString(): String start end Generic List Problem!!! l.append(l) Inheritance Better List Inheritance Node + data: Item + next: Node + Node(Item, Node) MyList - Node: start - Node: end + MyList () + append(Item) + appendList(MyList) "Interface" Item + clone(): Item + toString(): String NumeralItem - int: value + NumeralItem(int) StringItem - String: value + StringItem(int) . | Inheritance - Review Object-oriented programming Expressions Inheritance "interface" Expression + asString(): String + evaluate(): int "interface" BinaryExpression + left(): Expression + right(): Expression Numeral - int: value + Numeral(int) + Numeral() Square - Expression: expression + Square(Expression) Addition - Expression: left - Expression: right + Addition(Expression, Expression) Inheritance Generic Stack . 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(); class MyStack { . public void push(Object obj) {.} public Object pop() {.} } Generic List Inheritance MyList l = new MyList(); l.append(1); 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) Node + data: Object + next: Node + Node(Object, Node) MyList - Node: start - Node: end + MyList () + append(Object) + appendList(MyList) + toString(): String start end Generic List Problem!!! l.append(l) Inheritance Better List Inheritance Node + data: Item + next: Node + Node(Item, Node) MyList - Node: start - Node: end + MyList () + append(Item) + appendList(MyList) "Interface" Item + clone(): Item + toString(): String NumeralItem - int: value + NumeralItem(int) StringItem - String: value + StringItem(int)