Danh mục

Inheritance Review_Object-oriented programming

Số trang: 6      Loại file: ppt      Dung lượng: 391.00 KB      Lượt xem: 3      Lượt tải: 0    
Jamona

Hỗ trợ phí lưu trữ khi tải xuống: 3,000 VND Tải xuống file đầy đủ (6 trang) 0

Báo xấu

Xem trước 2 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Inheritance ReviewObject-oriented programming.ExpressionsNumeral - int: value + Numeral(int) + Numeral()"interface" Expression+ asString(): String + evaluate(): intSquare - Expression: expression + Square(Expression)"interface"
Nội dung trích xuất từ tài liệu:
Inheritance Review_Object-oriented programmingInheritance -ReviewObject-oriented programmingExpressions 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 2Generic 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 startGeneric 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 4Generic List Problem!!! l.append(l)Inheritance 5Better 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

Tài liệu được xem nhiều: