1. Trang chủ
  2. » Công Nghệ Thông Tin

Inheritance Review_Object-oriented programming doc

5 107 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Cấu trúc

  • Inheritance - Review

  • Expressions

  • Generic List

  • Slide 5

  • Better List

Nội dung

Inheritance - Review Object-oriented programming Expressions Inheritance 2 "interface" Expression + asString(): String + evaluate(): int "interface" BinaryE xpression + left(): Expression + right(): Expression Numeral - int: value + Numeral(int) + Numeral() Square - Expression: expression + Square(Expression) Addition - Expression: left - Expression: right + Addition(Expression, Expression) Generic List Inheritance 4 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 5 Better List Inheritance 6 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 2 "interface" Expression + asString(): String +. appendList(MyList) + toString(): String start end Generic List Problem!!! l.append(l) Inheritance 5 Better List Inheritance 6 Node + data: Item + next: Node + Node(Item, Node) MyList - Node: start -. Square(Expression) Addition - Expression: left - Expression: right + Addition(Expression, Expression) Generic List Inheritance 4 MyList l = new MyList(); l.append(1); l.append(2); System.out.println(l); // (1,

Ngày đăng: 05/07/2014, 15:20

TỪ KHÓA LIÊN QUAN