tailieunhanh - Inheritance Review_Object-oriented programming

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(); (p); (c); Circle c1 = (Circle) (); Point p1 = (Point) (); class MyStack { . public void push(Object obj) {.} public Object pop() {.} } Generic List Inheritance MyList l = new MyList(); (1); (2); (l); // (1, 2) MyList l2 = new MyList(); (3); (4); (l2); // (3, 4) (l2); (l); // (1, 2, (3, 4)) (l2); (l); // (1, 2, (3, 4), 3, 4) (5); (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) 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(); (p); (c); Circle c1 = (Circle) (); Point p1 = (Point) (); class MyStack { . public void push(Object obj) {.} public Object pop() {.} } Generic List Inheritance MyList l = new MyList(); (1); (2); (l); // (1, 2) MyList l2 = new MyList(); (3); (4); (l2); // (3, 4) (l2); (l); // (1, 2, (3, 4)) (l2); (l); // (1, 2, (3, 4), 3, 4) (5); (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) 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)

TÀI LIỆU LIÊN QUAN