.Open CS320/05 Questions UML Semantics . Using the UML We will be using the UML in notes, projects, labs, and final questions. It is perfect for describing:(1) the structure of a language, (2) the internal data structures used in compilers and interpreters, and (3) the meaning of each part of the language. In any session or anywhere in the final I may ask you to draw and/or interpret diagrams using the UML. Here is a question on semantics that I ask on finals: Give an example of how your project team described the semantics of its language. . Question 1a Model of Work in this class Draw a UML diagram of the following classes and associations. Do not show any operations or attributes! Use the following class names: Student, PieceOfWork, Date, SequenceNumber, TypeOfWork. Relationships: Each student does several pieces of work. Each piece of work is done by one student on a particular date. Each piece of work is of a particular type. Each piece of work has a sequence number. . Question 1b Add multiplicities and some role names to your diagram. Suggested role names: does, doneBy, etc.. Answer: .See ./05a.html In the following work as a group of 4-6 people. When you have a solution (or 2) wait for a chance to present the diagrams to the class. . Question 2a Model of the Java 1.0 AWT Class Library Draw a UML diagram of the following classes and relationships (Note. these are taken from the Java library of classes): Integer and Float are sub-types of Object. All Applets are Panels, all Panels are Containers, all Containers are Components, and all Components are Objects. Some other Components are Buttons, Lists, and TextFields. Answer: .See ./05a.html . Question 2b What do you add to the previous model to show that: a Container can have any number of Components inside it? . Question 3a Compositions Draw a UML diagram that uses composition (not attributes) to model the following C++ class: .As_is class Wodget { public: float size; int knobs; string id; }; Answer: .See ./05a.html . Question 3b Draw a UML diagram that uses attributes (not composition) to model the C++ Wodget class above. Answer: .See ./05a.html . Question 4 Lab work/Web site Draw a UML diagram of the part of your web site that is concerned with this class. Include the following ideas: Your_Home_Page, Your_CS320_Page, Lab_Page, Source_Code_Page. Answer: .See ./05a.html . Question 5 LISP Data Draw a UML diagram of a Node where: A Node is either Empty, an Atom, or a Pair. Each Pair has two pointers to nodes called the car and cdr of the Pair. Answer: .See ./05a.html . Question 6 Syntax and Semantics Which diagram (1,2,3) matches best each XBNF definition (alpha, beta, gamma) in this .See ./05xab.png diagram. . Question 6a Syntax For each syntax in .See ./05xab.png give a string of "a"s and "b"s that fit that syntax and see if it also fits the other two. Which syntax is most general -- every string that fits the other two must also fit it. .Open Question 7 MiniCalc Syntax and Semantics MiniCalc is a program that accepts simple expressions typed in by the user and evaluates them. MiniCalc uses simple integer Expressions: Expression ::= $Constant | $Operation. All expressions can be evaluated and return an Int as a value. .As_is 123 .As_is 1+2 Constant ::= digit #digit. The evaluation of a constant returns its value. (This was defined in an earlier session). .As_is 123 evaluate("123") = 123. Operation::= $Constant $Operator $Expression. First the Expression is evaluated and then the Constant. .As_is 1+2 The Operator is applied to these values to calculate the value of the Operation. Operator ::= "+" | "-" | "*" | "/". .As_is + Each operator has an `apply` function that takes two values and returns a value. .As_is apply(left:Int, right:Int): Int Draw a diagram, using the UML, that describes the classes of objects (Expression, Constant, Operation, Operator) plus their semantics. Do not show any syntax! Answer: .See ./05a.html .Close . OO Classroom Activity To Be Announced: Given the UML description of .... students are asked to simulate various the objects collaborating. . Answers .See http://www/dick/cs320/05a.html . Review Think back over this class and grade your personal performance in terms of how much work you need to do on this topic before the final. .Close