[Skip Navigation] [CSUSB] / [CNS] / [CSE] / [R J Botting] /[CS320 Course Materials] /05q.html [05q.txt(Text)] [Search ]
Thu Apr 5 13:07:48 PDT 2012
[Schedule] [Syllabi] [Text] [Labs] [Projects] [Resources] [Grading] [Contact]
Notes: [01] [02] [03] [04] [05] [06] [07] [08] [09] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20]


    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:
    1. 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: [ 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: [ 05a.html ]

      Question 2b

      What do you add to the previous model to show that:
    2. 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:
       	class Wodget { public: float size; int knobs; string id; };

      Answer: [ 05a.html ]

      Question 3b

      Draw a UML diagram that uses attributes (not composition) to model the C++ Wodget class above.

      Answer: [ 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: [ 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: [ 05a.html ]

      Question 6 Syntax and Semantics

      Which diagram (1,2,3) matches best each XBNF definition (alpha, beta, gamma) in this [ 05xab.png ] diagram.

      Question 6a Syntax

      For each syntax in [ 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.

      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:

      1. Expression::= Constant | Operation. All expressions can be evaluated and return an Int as a value.

      2. Constant::= digit #digit. The evaluation of a constant returns its value. (This was defined in an earlier session).
      3. evaluate("123") = 123.

      4. Operation::= Constant Operator Expression. First the Expression is evaluated and then the Constant.

      5. The Operator is applied to these values to calculate the value of the Operation.

      6. Operator::= "+" | "-" | "*" | "/".
      7. Each operator has an apply function that takes two values and returns a value.
         		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: [ 05a.html ]

      OO Classroom Activity

      To Be Announced: Given the UML description of .... students are asked to simulate various the objects collaborating.


      [ 05a.html ]


      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.