




































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An in-depth exploration of the concepts of object-oriented programming (oop) and object-oriented languages (ool). It covers the definitions, observations, and features of oop and ool, with a focus on classes, inheritance, encapsulation, and polymorphism. The document also includes examples of java code and comparisons between oop in ml and non-oop in java.
Typology: Slides
1 / 44
This page cannot be seen from the preview
Don't miss anything!





































Chapter Sixteen Modern Programming Languages, 2nd ed. (^) Docsity.com 1
Chapter Sixteen Modern Programming Languages, 2nd ed. (^) Docsity.com 2
Chapter Sixteen Modern Programming Languages, 2nd ed. (^) Docsity.com 4
Chapter Sixteen Modern Programming Languages, 2nd ed. 5
public class Node { private String data; private Node link; public Node(String theData, Node theLink) { data = theData; link = theLink; } public String getData() { return data; } public Node getLink() { return link; } }
Docsity.com
Chapter Sixteen Modern Programming Languages, 2nd ed. 7
datatype message = GetData | GetLink;
datatype response = Data of string | Object of message -> response;
fun node data link GetData = Data data | node data link GetLink = Object link;
Docsity.com
Chapter Sixteen Modern Programming Languages, 2nd ed. 8
Docsity.com
Chapter Sixteen Modern Programming Languages, 2nd ed. 10
datatype message = IsNull | Add of string | HasMore | Remove | GetData | GetLink;
datatype response = Pred of bool | Data of string | Removed of (message -> response) * string | Object of message -> response;
fun root _ = Pred false;
Docsity.com
Chapter Sixteen Modern Programming Languages, 2nd ed. 11
fun null IsNull = Pred true | null message = root message;
fun node data link GetData = Data data | node data link GetLink = Object link | node _ _ message = root message;
fun stack top HasMore = let val Pred(p) = top IsNull in Pred(not p) end | stack top (Add data) = Object(stack (node data top)) | stack top Remove = let val Object(next) = top GetLink val Data(data) = top GetData in Removed(stack next, data) end | stack _ message = root message;
Docsity.com
Chapter Sixteen Modern Programming Languages, 2nd ed. 13
fun peekableStack top Peek = top GetData | peekableStack top message = stack top message;
Docsity.com
Chapter Sixteen Modern Programming Languages, 2nd ed. (^) Docsity.com 14
Chapter Sixteen Modern Programming Languages, 2nd ed. (^) Docsity.com 16
Chapter Sixteen Modern Programming Languages, 2nd ed. 17
public class Node { public String data; // Each node has a String... public Node link; // ...and a link to the next Node }
public class Stack{ public Node top; // The top node in the stack }
Docsity.com
Chapter Sixteen Modern Programming Languages, 2nd ed. (^) Docsity.com 19
Chapter Sixteen Modern Programming Languages, 2nd ed. 20
public class Worklist { public static final int STACK = 0; public static final int QUEUE = 1; public static final int PRIORITYQUEUE = 2; public int type; // one of the above Worklist types public Node front; // front Node in the list public Node rear; // unused when type==STACK public int length; // unused when type==STACK }
Docsity.com