Plan for rest of course
|
|
- Carol Cooper
- 5 years ago
- Views:
Transcription
1 Plan for rest of course week 9-10 Converting CSP into JCSP architectures Include visualisation of these networks of processes to build graphical simulations. Already seen buttons but we need to know about canvases. Learn more about translation into JCSP so that we can build bigger networks week 9 Exam Structure week 11 Revision, including re-visiting CSP in order to look at safety specifications with another example COM2007 1
2 Exam Structure 3 compulsory questions question 1- demonstrate understanding of princinples and concepts of JCSP(40 marks) question 2 - CSP specification (20 marks) question 3 - modelling behaviour and defining concurrent architectures based on a scenario (40 marks) COM2007 2
3 Simple Car Park Monitoring COM2007 3
4 How to convert the abstract models channel arrive,depart maxcars = 4 CARPARKCONTROL = FILLED(0) FILLED(i) = (i < maxcars) & arrive -> FILLED(i+1) [] (i > 0) & depart -> FILLED(i-1) ARRIVALS = arrive -> ARRIVALS DEPARTURES = depart -> DEPARTURES AC = {arrive,depart} AA = {arrive} AD = {depart} CARPARK = (ARRIVALS [AA AD] DEPARTURES) [union(aa,ad) AC] CARPARKCONTROL COM2007 4
5 Key features of car park example Look to see what the key synchronisations are in the model Look to see what conditions need to hold for the synchronisations. The CarParkControl is acting like a monitor Single access procedure in the monitor ARRIVALS and DEPARTURES are acting like active entities (threads) COM2007 5
6 We model arrive using a, depart using b which are One2OneInt channels Since arrival and departure were external events we needed a way of simulating this to trigger them to happen so we put a graphics layer on top COM2007 6
7 Let s start with a frame Let s define a class which allows me to create a frame. It s just an outer shell. public class eg_frame { public static void main(string argv[]) { final ActiveClosingFrame activeclosingframe = new ActiveClosingFrame( "Lec 13 building simple frame"); final Frame frame = activeclosingframe.getactiveframe(); frame.setsize(400, 400); frame.setvisible(true); new Parallel(new CSProcess[] { activeclosingframe } ).run(); }} It s not necessary to define a parallel object at this point but I m doing it now so that you can see how to slot in the canvas in a little while (with ease). COM2007 7
8 Can we add a canvas? We can draw on an ActiveCanvas. (You can also be able to interact with it.) Declaring an active canvas object in the same file as the frame. final ActiveCanvas canvas = new ActiveCanvas (); canvas.setpaintable (displaylist); canvas.setsize (600, 400); We could separate out the canvas definition to be in its own class. For example, defining a new class where canvas will be a private variable. Then in the constructor create a new canvas. How will you know it s size. Well two ways: either give it explicitly or query the frame size. Example file Canvas_lec13.java To link it to the frame in the main java program define a canvas object and make it run in parallel with the frame. final Canvas_lec13 canvas = new Canvas_lec13(frame); COM2007 8
9 Example skeleton class Canvas_lec13 implements CSProcess{ private final ActiveCanvas activecanvas; public Canvas_lec13(final Container parent){ System.out.println ("canvas_lec13 now creating ActiveCanvas..."); activecanvas = new ActiveCanvas (); activecanvas.setsize (parent.getsize ()); } System.out.println ("canvas_lec13 adding ActiveCanvas to the parent..."); parent.add ("Center", activecanvas); } public void run () { activecanvas.run(); } Again we ll need to define a parallel object in due course in the run method. COM2007 9
10 How do we change the colour of the background on a frame? You can do this in the outer class where you defined the frame, or you can do it in the canvas class. You should call the appropriate methods for the frame object. For example, if we did it in the canvas class we d use the parameter passed to the constructor and then: parent.setlayout (new BorderLayout ()); parent.setbackground (Color.blue); COM
11 How do we get graphics onto a canvas? A DisplayList is a passive object providing graphics services on behalf of a CSProcess. It enables all methods of java.awt.graphics to be executed on the active graphics component. In JCSP when we define a DisplayList object it provides an instance of a Paintable class. Then we can pass this as an argument to the setpaintable method so that we can connect the DisplayList to the ActiveCanvas. The definition of setpaintable is defined as public void setpaintable(paintable paintable). COM
12 Display List (continued) In JCSP we can think of DisplayList as a special form of channel. The user process sees the display interface to the DisplayList so that a user process writes to it by setting up and/or editing an ordered list of GraphicsCommands. The ActiveCanvas process sees the Paintable interface to the DisplayList (reads). Therefore, a DisplayList gives you two views and a secure interface between an active user process and an active graphics component. From JCSP docs: DisplayList user process >>> ActiveCanvas Display Paintable COM
13 What would the code look like to define a DisplayList object? So if we were doing it in one large file we do: final DisplayList displaylist = new DisplayList (); final ActiveCanvas canvas = new ActiveCanvas (); canvas.setpaintable (displaylist); whereas in a class structured program you would define a private variable private final DisplayList displaylist; and then have: displaylist = new DisplayList (); activecanvas.setpaintable(displaylist); COM
14 Graphics Command User processes send an array of GraphicsCommands by invoking set, change methods to the DisplayList object. It is a class jcsp.awt.graphicscommand. E.g. GraphicsCommand.DrawImage corresponds to java.awt.graphics.drawimage. The following draws a background colour, a rectangle with a message in black in the center. final GraphicsCommand[] myfilledrect = {new GraphicsCommand.SetColor (Color.cyan), new GraphicsCommand.FillRect (0, 0, 600, 400), new GraphicsCommand.SetColor (Color.black), new GraphicsCommand.DrawString ("hello", 145, 200)}; displaylist.set(myfilledrect); COM
15 Experimenting in one large file (yuck...) new Parallel(new CSProcess[] { activeclosingframe, canvas, new CSProcess() { public void run() { final GraphicsCommand[] myfilledrect = { new GraphicsCommand.SetColor(Color.cyan), new GraphicsCommand.FillRect(0, 0, 600, 400), new GraphicsCommand.SetColor(Color.black), new GraphicsCommand.DrawString("hello", 145, 200) }; displaylist.set(myfilledrect); } } }).run(); Example eg_framecanvascolour.java draws a filled rectangle on a canvas in a frame and eg_framecanvaschangingcolour.java draws a filled rectangle on a canvas in a frame which changes colour after a delay. COM
16 How would we make use of graphics commands using a class structured program? We d have three classes - one for the frame, one for the canvas and display list and one for what s going on inside the canvas i.e. what we want to see. Let s first look at Canvasv2_lec13.java. We d need to have a circle variable. private final Circle circle; /* in the privately scoped area of class */ circle = new Circle(displayList); /* goes in constructor */ public void run () { /* then we need to run it in parallel with the canvas */ new Parallel ( new CSProcess[] { activecanvas, circle } ).run (); Ah, this means that the circle object will be a process. COM
17 Let s make a simple user process Consider a Circle class. The following sets up a circle display object in the java program where the parallel processes are defined. We ve just seen: Circle circle = new Circle(displayList); The above means that the Circle object can write along the DisplayList channel to the canvas. Therefore, the constructor in the Circle class definition is given in the following: public class Circle implements CSProcess { DisplayList displaylist; // for graphics public Circle(DisplayList displaylist){ this.displaylist = displaylist; }... Then we can use the displaylist.set(...) calls in the run method. Typically, we define private functions which are called in the run method to capture the setting up of the graphics so that the code is well structured (see Circle.java). COM
18 Examples so far The eg_frame.java is a simple example of just getting a frame constructed The eg_framecanvas.java is a simple example of just a frame and a canvas The eg_framecanvascolour.java is one large program which displays a colour on a canvas. The eg_framecanvaschangingcolour.java is one large program which displays a colour on a canvas that changes with a delay. The eg_displaylist.java and Canvas_v2.java and Circle.java is a good overall structure for developing a graphics application The MyCircleTest2.java adds a buttons so that the execution of the circle can be paused/unpaused. You can run this example yourselves. It makes use of gridbaglayout to organise the layout. COM
19 Returning to Car Park Example-Arrival Class Need a way of simulating arrival at regular intervals so that output communication that car arrived can be sent to the CarPark Set up output channel for arrival of car (will be a one2one communication channel a with CarPark) Set up timer to control display (is internal communication, bit more complex than the skip we ve seen in the lab in week 9) Set up events to control button, normally two: event and change (similar to the freeze control events we ve seen in week 8 and are one2one communications with the button) COM
20 final Guard[] altchannels = { event, tim }; final Alternative alt = new Alternative(altChannels); Arrival Class code structure while (true) { int i = 0; while (i < 360) // for 1 complete circle { switch (alt.priselect()) { case EVENT: if (event.read() == " Pause ") { change.write("unpause"); // change button label and wait for event.read(); change.write(" Pause "); // unpausing button event } break; case TIM: // wait for 1 interval then update timeout = tim.read() + interval; tim.after(timeout); tick(l); //update graphics l = (l + 1) % 360; i++; break; } } // after 1 complete circle output to car park out.write(1); i = 0; } COM
21 Returning to Car Park Example-CarPark Class Set up an attribute to represent the i variable in the FILLED process which records the number of cars in the car park Set up an alternative to be the choice between the arrival and departure of a car, we will monitor this as inputs from the a and b channels. Iteratively do the following: Need to check whether can accept the communication or not, can do this with a simple if or a pre-condition in the alting statement In each case read the communication. BUT the value being communicated is not important so can throw it away or send dummy information. This is the way to map atomic events into JCSP Also update the i attribute and update the graphics COM
22 CarPark Class Code Structure final Guard[] altchannels = {in, request}; final Alternative alt = new Alternative(altChannels); // alt over arrivals and request for a departure while(true) { switch (alt.fairselect()) { case IN: // arrival if(n<4) // can accept an arrival { in.read(); // read in arrival n++; spaces(n); // update car park graphics } break; } } case REQUEST: // requests a departure if(n>0) // at least 1 car in car park { request.read(); // read request out.write(1); // output car n--; spaces(n); // update car park } break; COM
23 Returning to Car Park Example-Departure Class Has a mirrored structure to the Arrival class However, we have added a simple protocol for an acknowledge of the request to leave the car park. This is not included in the CSP but is one way to refine the model so that you can include more communication if necessary. This acknowledge protocol could mean that the CarPark class first has to lift the barrier, this could be reflected in the graphic. COM
24 Departure class Code Structure final Guard[] altchannels = {event, tim}; final Alternative alt = new Alternative(altChannels); while (true) { int i = 0; while(i<360) // for 1 complete circle { switch (alt.priselect()) { case EVENT: //deal with pausing the button case TIM: //wait for time interval and update the graphic } //after 1 complete circle request from car park and read in request.write(1); in.read(); i=0; //reset the circle variable } COM
25 Putting it all together All channels need to be defined in a Main class which is not part of the diagram structure. All the channels in this case study are simple One2One channels Alting structures have been introduced in CarPark to reflect the ones in the CSP class Alting structures have been introduced in the Arrival and Departure class in order to time the output/input communication. new Parallel(new CSProcess[] { activeclosingframe, activecanvas, button, button2, arrival, departure, carpark }).run(); COM
26 Recap of Lab 4 cars on a bridge COM
27 Architecture COM
28
29
30 Assumptions and Simplications Combine the MAINLIGHT, ISLANDLIGHT and BRIDGE together into one class. Then the combined new Bridge class can control the ordering of the offmainland, offisland, mturngreen, mturnred, iturnred and iturngreen. So in effect it is combining the state machines of these three processes. This is a non-trivial task. (Hint: one way to start is to re-write the CSP processses as one process, stepping through what transitions are possible at each step.) Resolved the non-determinism in TCONTROL so that I give the traffic lights a prescribed sequence pattern. Since CSP is a modelling language the simulations can be refinements of the abstract models and provide a definite behaviour. Make the simulation easier by only looking at the flow of traffic from the mainland to the island. COM
COM2007 Week 9 Java Concurrency and Alting
COM2007 Week 9 Java Concurrency and Alting Two Learning Outcomes: To provide a comparison of how threads run in Java and also to develop a working example using the AltingChannel constructs. Part 1 is
More informationCOMP30112: Concurrency Topics 4.1: Concurrency Patterns - Monitors
COMP30112: Concurrency Topics 4.1: Concurrency Patterns - Monitors Howard Barringer Room KB2.20: email: Howard.Barringer@manchester.ac.uk February 2009 Outline Monitors FSP Models-to-Java Monitors Producers/Consumers
More informationDesign Of JCSP Language Classes
Design Of JCSP Language Classes Paul Austin pda1@ukc.ac.uk University Of Kent Canterbury BSc Computer Science with an Industrial Year 3 rd Year Project Paul David Austin 1-May-1998 Contents 1 Introduction...1
More informationC340 Concurrency: Semaphores and Monitors. Goals
C340 Concurrency: Semaphores and Monitors Wolfgang Emmerich 1 Goals Introduce concepts of Semaphores Monitors Implementation in Java synchronised methods and private attributes single thread active in
More informationAn Introduction to the Kent C++CSP Library. Authors Neil Brown Peter Welch
An Introduction to the Kent C++CSP Library Authors Neil Brown (neil@twistedsquare.com) Peter Welch (P.H.Welch@kent.ac.uk) C++ Overview Object-oriented but not pure objectoriented like Smalltalk C++ provides
More informationLecture 9: Introduction to Monitors
COMP 150-CCP Concurrent Programming Lecture 9: Introduction to Monitors Dr. Richard S. Hall rickhall@cs.tufts.edu Concurrent programming February 14, 2008 Abstracting Locking Details Recall our discussion
More informationProcess Oriented Design for Java - Concurrency for All
Process Oriented Design for Java - Concurrency for All Peter Welch (p.h.welch@kent.ac.uk) Computing Laboratory, University of Kent at Canterbury Co631 (Concurrency Design and Practice) 1-Apr-08 Copyright
More informationMonitors & Condition Synchronization
Feb. 15, 2012 Monitors & condition Synchronization Concepts: monitors: encapsulated data + access procedures mutual exclusion + condition synchronization single access procedure active in the monitor Models:
More informationMonitors & Condition Synchronization
Chapter 5 Monitors & Condition Synchronization monitors & condition synchronization Concepts: monitors: encapsulated data + access procedures mutual exclusion + condition synchronization single access
More informationCT 229 Arrays in Java
CT 229 Arrays in Java 27/10/2006 CT229 Next Weeks Lecture Cancelled Lectures on Friday 3 rd of Nov Cancelled Lab and Tutorials go ahead as normal Lectures will resume on Friday the 10 th of Nov 27/10/2006
More informationExam Concurrent and Real-Time Programming
LUNDS TEKNISKA HÖGSKOLA 1(6) Institutionen för datavetenskap Exam Concurrent and Real-Time Programming 2009 12 16, 08.00 13.00 You are allowed to use the Java quick reference and a calculator. Also dictionaries
More informationMonitors & Condition Synchronisation
Chapter 5 Monitors & Condition Synchronisation controller 1 Monitors & Condition Synchronisation Concepts: monitors (and controllers): encapsulated data + access procedures + mutual exclusion + condition
More informationCSCI 5828: Foundations of Software Engineering
CSCI 5828: Foundations of Software Engineering Lecture 16: Monitors & Condition Synchronization Slides created by Magee and Kramer for the Concurrency textbook 1 Chapter 5 Monitors & Condition Synchronization
More informationOBJECT ORIENTED PROGRAMMING
1. Programming Paradigms OBJECT ORIENTED PROGRAMMING A programming methodology defines the methodology of designing and implementing programs using the key features and other building blocks (such as key
More informationUMBC CMSC 331 Final Exam Section 0101 December 17, 2002
0 / 0 1 / 20 UMBC CMSC 331 Final Exam Section 0101 December 17, 2002 Name: Student ID#: 2 / 25 3 / 20 4 / 25 5 / 20 6 /40 7 /40 You will have two hours to complete this closed book exam. We reserve the
More informationANSWER KEY Exam 2 Computer Programming 230 Dr. St. John Lehman College City University of New York Thursday, 5 November 2009
ANSWER KEY Exam 2 Computer Programming 230 Dr. St. John Lehman College City University of New York Thursday, 5 November 2009 1. True or False: (a) T In Alice, there is an event that is processed as long
More informationMODEL-BASED DEVELOPMENT -TUTORIAL
MODEL-BASED DEVELOPMENT -TUTORIAL 1 Objectives To get familiar with the fundamentals of Rational Rhapsody. You start with the simplest example possible. You end with more complex functionality, and a more
More informationCMSC 433 Programming Language Technologies and Paradigms. Concurrency
CMSC 433 Programming Language Technologies and Paradigms Concurrency What is Concurrency? Simple definition Sequential programs have one thread of control Concurrent programs have many Concurrency vs.
More informationComputer Science II (20082) Week 1: Review and Inheritance
Computer Science II 4003-232-08 (20082) Week 1: Review and Inheritance Richard Zanibbi Rochester Institute of Technology Review of CS-I Syntax and Semantics of Formal (e.g. Programming) Languages Syntax
More informationChapter 7 Exercise Solutions
Chapter 7 Exercise Solutions EX 7.1. Write a method called average that accepts two integer parameters and returns their average as a floating point value. public double average (int num1, int num2) return
More information1 Shyam sir JAVA Notes
1 Shyam sir JAVA Notes 1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write
More informationCS 211: Methods, Memory, Equality
CS 211: Methods, Memory, Equality Chris Kauffman Week 2-1 So far... Comments Statements/Expressions Variable Types little types, what about Big types? Assignment Basic Output (Input?) Conditionals (if-else)
More informationFinal Examination Semester 2 / Year 2010
Southern College Kolej Selatan 南方学院 Final Examination Semester 2 / Year 2010 COURSE : JAVA PROGRAMMING COURSE CODE : PROG1114 TIME : 2 1/2 HOURS DEPARTMENT : COMPUTER SCIENCE LECTURER : LIM PEI GEOK Student
More informationProgramming Languages and Techniques (CIS120)
Programming Languages and Techniques (CIS120) Lecture 26 March 23, 2016 Inheritance and Dynamic Dispatch Chapter 24 Inheritance Example public class { private int x; public () { x = 0; } public void incby(int
More informationThe Java Memory Model
The Java Memory Model What is it and why would I want one? Jörg Domaschka. ART Group, Institute for Distributed Systems Ulm University, Germany December 14, 2009 public class WhatDoIPrint{ static int x
More informationProgramming Language Concepts: Lecture 11
Programming Language Concepts: Lecture 11 Madhavan Mukund Chennai Mathematical Institute madhavan@cmi.ac.in PLC 2011, Lecture 11, 01 March 2011 Concurrent Programming Monitors [Per Brinch Hansen, CAR Hoare]
More informationSequence Diagram. A UML diagram used to show how objects interact. Example:
Sequence Diagram A UML diagram used to show how objects interact. Example: r: Register s: Sale makepayment() makepayment() new() : Payment The above starts with a Register object, r, receiving a makepayment
More informationMaking New instances of Classes
Making New instances of Classes NOTE: revised from previous version of Lecture04 New Operator Classes are user defined datatypes in OOP languages How do we make instances of these new datatypes? Using
More informationMonitors & Condition Synchronization
Chapter 5 Monitors & Condition Synchronization controller 1 Monitors & Condition Synchronization Concepts: monitors (and controllers): encapsulated data + access procedures + mutual exclusion + condition
More informationJAVA GUI PROGRAMMING REVISION TOUR III
1. In java, methods reside in. (a) Function (b) Library (c) Classes (d) Object JAVA GUI PROGRAMMING REVISION TOUR III 2. The number and type of arguments of a method are known as. (a) Parameter list (b)
More informationJava Classes - Using your classes. How the classes you write are being used
Java Classes - Using your classes How the classes you write are being used What s the use of classes? So, you have been writing a few classes by now... What for? The programs you will write will use objects
More informationComputation Abstractions. Processes vs. Threads. So, What Is a Thread? CMSC 433 Programming Language Technologies and Paradigms Spring 2007
CMSC 433 Programming Language Technologies and Paradigms Spring 2007 Threads and Synchronization May 8, 2007 Computation Abstractions t1 t1 t4 t2 t1 t2 t5 t3 p1 p2 p3 p4 CPU 1 CPU 2 A computer Processes
More information1.00 Introduction to Computers and Engineering Problem Solving Quiz 1 March 4, 2005
1.00 Introduction to Computers and Engineering Problem Solving Quiz 1 March 4, 2005 Name: E-mail Address: TA: Section: You have 80 minutes to complete this exam. For coding questions, you do not need to
More informationSequence Diagram. r: Register s: Sale
ACS-3913 1 Sequence Diagram A UML diagram used to show how objects interact. Example: r: Register s: Sale makepayment() makepayment() new() : Payment The above starts with a Register object, r, receiving
More informationChapter 5: Methods. by Tony Gaddis. Starting Out with Java: From Control Structures through Objects. Fourth Edition
Chapter 5: Methods Starting Out with Java: From Control Structures through Objects Fourth Edition by Tony Gaddis Addison Wesley is an imprint of 2010 Pearson Addison-Wesley. All rights reserved. Reading
More information+ Inheritance. Sometimes we need to create new more specialized types that are similar to types we have already created.
+ Inheritance + Inheritance Classes that we design in Java can be used to model some concept in our program. For example: Pokemon a = new Pokemon(); Pokemon b = new Pokemon() Sometimes we need to create
More informationObject Oriented Programming is a programming method that combines: Advantage of Object Oriented Programming
Overview of OOP Object Oriented Programming is a programming method that combines: a) Data b) Instructions for processing that data into a self-sufficient object that can be used within a program or in
More informationCLASSES AND OBJECTS. Fundamentals of Computer Science I
CLASSES AND OBJECTS Fundamentals of Computer Science I Outline Primitive types Creating your own data types Classes Objects Instance variables Instance methods Constructors Arrays of objects A Foundation
More informationAbout this exam review
Final Exam Review About this exam review I ve prepared an outline of the material covered in class May not be totally complete! Exam may ask about things that were covered in class but not in this review
More informationSoftware and Programming 1
Software and Programming 1 Lab 8: Use of classes, static class variables and methods 1st March 2018 SP1-Lab8-2018.pdf Tobi Brodie (Tobi@dcs.bbk.ac.uk) 1 Lab 8 Objectives Understanding the encapsulation
More informationProcess Oriented Design for Java - Concurrency for All
Process Oriented Design for Java - Concurrency for All Peter Welch (phw@ukcacuk) Computing Laboratory, University of Kent at Canterbury ICCS 2002 (Global and Collaborative Computing, 22nd April, 2002)
More informationClass, Variable, Constructor, Object, Method Questions
Class, Variable, Constructor, Object, Method Questions http://www.wideskills.com/java-interview-questions/java-classes-andobjects-interview-questions https://www.careerride.com/java-objects-classes-methods.aspx
More informationSoftware Architecture
Software Architecture Lecture 5 Call-Return Systems Rob Pettit George Mason University last class data flow data flow styles batch sequential pipe & filter process control! process control! looping structure
More informationAgenda CS121/IS223. Reminder. Object Declaration, Creation, Assignment. What is Going On? Variables in Java
CS121/IS223 Object Reference Variables Dr Olly Gotel ogotel@pace.edu http://csis.pace.edu/~ogotel Having problems? -- Come see me or call me in my office hours -- Use the CSIS programming tutors Agenda
More informationCSC 172 Data Structures and Algorithms. Lecture 3 Spring 2018 TuTh 3:25 pm 4:40 pm
CSC 172 Data Structures and Algorithms Lecture 3 Spring 2018 TuTh 3:25 pm 4:40 pm Agenda Administrative aspects Java Generics Chapter 1 ADMINISTRATIVE ASPECTS Workshops Workshops Workshops begin on this
More informationComputer Science II (20073) Week 1: Review and Inheritance
Computer Science II 4003-232-01 (20073) Week 1: Review and Inheritance Richard Zanibbi Rochester Institute of Technology Review of CS-I Hardware and Software Hardware Physical devices in a computer system
More informationObject-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018
Object-oriented programming 1 and data-structures CS/ENGRD 2110 SUMMER 2018 Lecture 1: Types and Control Flow http://courses.cs.cornell.edu/cs2110/2018su Lecture 1 Outline 2 Languages Overview Imperative
More informationCS 101 Fall 2005 Midterm 2 Name: ID:
This exam is open text book but closed-notes, closed-calculator, closed-neighbor, etc. Questions are worth different amounts (in particular, the final two questions are worth substantially more than any
More informationArrays. COMS W1007 Introduction to Computer Science. Christopher Conway 10 June 2003
Arrays COMS W1007 Introduction to Computer Science Christopher Conway 10 June 2003 Arrays An array is a list of values. In Java, the components of an array can be of any type, basic or object. An array
More informationEvery language has its own scoping rules. For example, what is the scope of variable j in this Java program?
Lexical Binding There are two ways a variable can be used in a program: As a declaration As a "reference" or use of the variable Scheme has two kinds of variable "declarations" -- the bindings of a let-expression
More informationCSC 111, Test 1 (Fall 2009)
CSC 111, Test 1 (Fall 2009) Name There are 8 questions, many with sub-questions, as part of this test. Make sure you read and answer each question carefully and fully. Partial credit, while possible, will
More informationCS121/IS223. Object Reference Variables. Dr Olly Gotel
CS121/IS223 Object Reference Variables Dr Olly Gotel ogotel@pace.edu http://csis.pace.edu/~ogotel Having problems? -- Come see me or call me in my office hours -- Use the CSIS programming tutors CS121/IS223
More informationBasic Keywords Practice Session
Basic Keywords Practice Session Introduction In this article from my free Java 8 course, we will apply what we learned in my Java 8 Course Introduction to our first real Java program. If you haven t yet,
More informationNotes on the Exam. Question 1. Today. Comp 104:Operating Systems Concepts 11/05/2015. Revision Lectures (separate questions and answers)
Comp 104:Operating Systems Concepts Revision Lectures (separate questions and answers) Today Here are a sample of questions that could appear in the exam Please LET ME KNOW if there are particular subjects
More informationCOMPUTER PROGRAMMING LOOPS
COMPUTER PROGRAMMING LOOPS http://www.tutorialspoint.com/computer_programming/computer_programming_loops.htm Copyright tutorialspoint.com Let's consider a situation when you want to write five times. Here
More information1.00 Introduction to Computers and Engineering Problem Solving. Quiz 1 March 7, 2003
1.00 Introduction to Computers and Engineering Problem Solving Quiz 1 March 7, 2003 Name: Email Address: TA: Section: You have 90 minutes to complete this exam. For coding questions, you do not need to
More informationLecture 5: Implementing Lists, Version 1
CS18 Integrated Introduction to Computer Science Fisler, Nelson Lecture 5: Implementing Lists, Version 1 Contents 1 Implementing Lists 1 2 Methods 2 2.1 isempty...........................................
More informationPull Lecture Materials and Open PollEv. Poll Everywhere: pollev.com/comp110. Lecture 12. else-if and while loops. Once in a while
Pull Lecture Materials and Open PollEv Poll Everywhere: pollev.com/comp110 Lecture 12 else-if and while loops Once in a while Fall 2016 if-then-else Statements General form of an if-then-else statement:
More informationLecture Notes CPSC 224 (Spring 2012) Today... Java basics. S. Bowers 1 of 8
Today... Java basics S. Bowers 1 of 8 Java main method (cont.) In Java, main looks like this: public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World!"); Q: How
More informationLab 4: Imperative & Debugging 12:00 PM, Feb 14, 2018
CS18 Integrated Introduction to Computer Science Fisler, Nelson Lab 4: Imperative & Debugging 12:00 PM, Feb 14, 2018 Contents 1 Imperative Programming 1 1.1 Sky High Grades......................................
More informationComp 204: Computer Systems and Their Implementation. Lecture 25a: Revision Lectures (separate questions and answers)
Comp 204: Computer Systems and Their Implementation Lecture 25a: Revision Lectures (separate questions and answers) 1 Today Here are a sample of questions that could appear in the exam Please LET ME KNOW
More informationLecture 11. Example 1. Introduction. Method definition and invocation. Parameter passing: value vs. reference parameters. Scope and Lifetime.
Lecture 11 Example 1 Method definition and invocation. Parameter passing: value vs. reference parameters. Scope and Lifetime. Constructors Material from Holmes Chapter 6: sections 1 through to 8, except
More informationSri Vidya College of Engineering & Technology
UNIT I INTRODUCTION TO OOP AND FUNDAMENTALS OF JAVA 1. Define OOP. Part A Object-Oriented Programming (OOP) is a methodology or paradigm to design a program using classes and objects. It simplifies the
More informationBuilding custom components IAT351
Building custom components IAT351 Week 1 Lecture 1 9.05.2012 Lyn Bartram lyn@sfu.ca Today Review assignment issues New submission method Object oriented design How to extend Java and how to scope Final
More informationIntroduction to the Java Basics: Control Flow Statements
Lesson 3: Introduction to the Java Basics: Control Flow Statements Repetition Structures THEORY Variable Assignment You can only assign a value to a variable that is consistent with the variable s declared
More informationChapter. We've been using predefined classes. Now we will learn to write our own classes to define objects
Writing Classes 4 Chapter 5 TH EDITION Lewis & Loftus java Software Solutions Foundations of Program Design 2007 Pearson Addison-Wesley. All rights reserved Writing Classes We've been using predefined
More informationObject-Interaction Diagrams: Sequence Diagrams UML
Object-Interaction Diagrams: Sequence Diagrams UML Communication and Time In communication diagrams, ordering of messages is achieved by labelling them with sequence numbers This does not make temporal
More informationCIS 110: Introduction to Computer Programming. Lecture 2 Decomposition and Static Methods ( 1.4)
CIS 110: Introduction to Computer Programming Lecture 2 Decomposition and Static Methods ( 1.4) Outline Structure and redundancy in algorithms Static methods Procedural decomposition 9/16/2011 CIS 110
More information1995 Paper 10 Question 7
995 Paper 0 Question 7 Why are multiple buffers often used between producing and consuming processes? Describe the operation of a semaphore. What is the difference between a counting semaphore and a binary
More informationCS1004: Intro to CS in Java, Spring 2005
CS1004: Intro to CS in Java, Spring 2005 Lecture #13: Java OO cont d. Janak J Parekh janak@cs.columbia.edu Administrivia Homework due next week Problem #2 revisited Constructors, revisited Remember: a
More informationName EID. (calc (parse '{+ {with {x {+ 5 5}} {with {y {- x 3}} {+ y y} } } z } ) )
CS 345 Spring 2010 Midterm Exam Name EID 1. [4 Points] Circle the binding instances in the following expression: (calc (parse '+ with x + 5 5 with y - x 3 + y y z ) ) 2. [7 Points] Using the following
More informationAutomatic Translation from Circus to Java
Automatic Translation from Circus to Java Angela Freitas and Ana Cavalcanti Department of Computer Science University of York, UK Abstract. Circus is a combination of Z and CSP that supports the development
More informationMethods. Every Java application must have a main method.
Methods Every Java application must have a main method. The JVM calls main when it runs your program. When main finishes control goes back to the JVM. Up to now, we have always coded public static void
More informationProgramming Languages and Techniques (CIS120)
Programming Languages and Techniques (CIS120) Lecture 26 March 26, 2015 Inheritance and Dynamic Dispatch Chapter 24 public interface Displaceable { public int getx(); public int gety(); public void move
More informationTHIS EXAMINATION PAPER MUST NOT BE REMOVED FROM THE EXAMINATION ROOM
UNIVERSITY OF LONDON GOLDSMITHS COLLEGE B. Sc. Examination 2012 COMPUTER SCIENCE IS52025A Internet and Distributed Programming Duration: 2 hours 15 minutes Date and time: There are five questions in this
More informationKickstart Intro to Java Part I
Kickstart Intro to Java Part I COMP346/5461 - Operating Systems Revision 1.6 February 9, 2004 1 Topics Me, Myself, and I Why Java 1.2.*? Setting Up the Environment Buzz about Java Java vs. C++ Basic Java
More informationCIS 110 Introduction To Computer Programming. October 5th, 2011 Exam 1. Review problems
CIS 110 Introduction To Computer Programming October 5th, 2011 Exam 1 Review problems Scores: 1 2 3 4 5 6 Total (100 max) CIS 110 Exam 1 Instructions You have 50 minutes to finish this exam. Time will
More informationMCS-378 Intraterm Exam 1 Serial #:
MCS-378 Intraterm Exam 1 Serial #: This exam is closed-book and mostly closed-notes. You may, however, use a single 8 1/2 by 11 sheet of paper with hand-written notes for reference. (Both sides of the
More informationProgramming for Engineers in Python
Programming for Engineers in Python Lecture 5: Object Oriented Programming Autumn 2011-12 1 Lecture 4 Highlights Tuples, Dictionaries Sorting Lists Modular programming Data analysis: text categorization
More informationNested Loops ***** ***** ***** ***** ***** We know we can print out one line of this square as follows: System.out.
Nested Loops To investigate nested loops, we'll look at printing out some different star patterns. Let s consider that we want to print out a square as follows: We know we can print out one line of this
More informationComputer Science 1 Ah
UNIVERSITY OF EDINBURGH course CS0077 FACULTY OF SCIENCE AND ENGINEERING DIVISION OF INFORMATICS SCHOOL OF COMPUTER SCIENCE Computer Science 1 Ah Degree Examination Date: Saturday 25th May 2002 Time: 09:30
More informationChapter 5 Control Statements: Part 2 Section 5.2 Essentials of Counter-Controlled Repetition
Chapter 5 Control Statements: Part 2 Section 5.2 Essentials of Counter-Controlled Repetition 5.2 Q1: Counter-controlled repetition requires a. A control variable and initial value. b. A control variable
More informationAdministration. Classes. Objects Part II. Agenda. Review: Object References. Object Aliases. CS 99 Summer 2000 Michael Clarkson Lecture 7
Administration Classes CS 99 Summer 2000 Michael Clarkson Lecture 7 Lab 7 due tomorrow Question: Lab 6.equals( SquareRoot )? Lab 8 posted today Prelim 2 in six days! Covers two weeks of material: lectures
More informationIntroduction This assignment will ask that you write a simple graphical user interface (GUI).
Computing and Information Systems/Creative Computing University of London International Programmes 2910220: Graphical Object-Oriented and Internet programming in Java Coursework one 2011-12 Introduction
More informationTHE UNIVERSITY OF WESTERN AUSTRALIA SAMPLE EXAM QUESTIONS 2007 WITH SOLUTIONS SCHOOL OF COMPUTER SCIENCE CITS3213 CONCURRENT PROGRAMMING (PART II)
THE UNIVERSITY OF WESTERN AUSTRALIA SAMPLE EXAM QUESTIONS 2007 WITH SOLUTIONS SCHOOL OF COMPUTER SCIENCE CITS3213 CONCURRENT PROGRAMMING (PART II) The exam will contain: 6 questions (3 for each part) Time
More informationJava Object Oriented Design. CSC207 Fall 2014
Java Object Oriented Design CSC207 Fall 2014 Design Problem Design an application where the user can draw different shapes Lines Circles Rectangles Just high level design, don t write any detailed code
More informationG51PGP Programming Paradigms. Lecture 009 Concurrency, exceptions
G51PGP Programming Paradigms Lecture 009 Concurrency, exceptions 1 Reminder subtype polymorphism public class TestAnimals public static void main(string[] args) Animal[] animals = new Animal[6]; animals[0]
More informationEECS 1001 and EECS 1030M, lab 01 conflict
EECS 1001 and EECS 1030M, lab 01 conflict Those students who are taking EECS 1001 and who are enrolled in lab 01 of EECS 1030M should switch to lab 02. If you need my help with switching lab sections,
More informationJAVA RMI. Remote Method Invocation
1 JAVA RMI Remote Method Invocation 2 Overview Java RMI is a mechanism that allows one to invoke a method on an object that exists in another address space. The other address space could be: On the same
More informationFinal Score ID Extra Credit. 15% of course grade
Name Final Score ID Extra Credit Section (circle one): TTh 8:00-9:20 TTh 9:30-10:50 TTh 11:00-12:20 15% of course grade 1. Inheritance When Java was developed, it was scrutinized since it only has single
More informationIntroduction to Java
Introduction to Java Module 1: Getting started, Java Basics 22/01/2010 Prepared by Chris Panayiotou for EPL 233 1 Lab Objectives o Objective: Learn how to write, compile and execute HelloWorld.java Learn
More informationObject Oriented Programming 2014/15. Final Exam July 3, 2015
Object Oriented Programming 2014/15 Final Exam July 3, 2015 Directions (read carefully): CLEARLY print your name and ID on every page. The exam contains 8 pages divided into 4 parts. Make sure you have
More informationJAVA Programming Language Homework I - OO concept
JAVA Programming Language Homework I - OO concept Student ID: Name: 1. Which of the following techniques can be used to prevent the instantiation of a class by any code outside of the class? A. Declare
More informationObject-Oriented Programming in Processing
Object-Oriented Programming in Processing Object-Oriented Programming We ve (kinda) been doing this since Day 1: Python is a deeply object oriented language Most of the data types we were using (strings,
More informationChapter 6 Introduction to Defining Classes
Introduction to Defining Classes Fundamentals of Java: AP Computer Science Essentials, 4th Edition 1 Objectives Design and implement a simple class from user requirements. Organize a program in terms of
More informationCOMP102: Test 2 Model Solutions
Family Name:.......................... Other Names:.......................... ID Number:............................ Instructions Time allowed: 90 minutes (1 1 2 hours). There are 90 marks in total. Answer
More informationCSE 142 Su01 Midterm 1 Sample Solution page 1 of 5
CSE 142 Su01 Midterm 1 Sample Solution page 1 of 5 Answer all of the following questions. READ EACH QUESTION CAREFULLY. Answer each question in the space provided on these pages. Budget your time so you
More informationJava Class Design. Eugeny Berkunsky, Computer Science dept., National University of Shipbuilding
Java Class Design Eugeny Berkunsky, Computer Science dept., National University of Shipbuilding eugeny.berkunsky@gmail.com http://www.berkut.mk.ua Objectives Implement encapsulation Implement inheritance
More informationChapter 12 Advanced GUIs and Graphics
Chapter 12 Advanced GUIs and Graphics Chapter Objectives Learn about applets Explore the class Graphics Learn about the classfont Explore the classcolor Java Programming: From Problem Analysis to Program
More informationObject-oriented development. Object-oriented Design. Objectives. Characteristics of OOD. Interacting objects. Topics covered
Object-oriented development Object-oriented Design Object-oriented analysis, design and programming are related but distinct. OOA is concerned with developing an object model of the application domain.
More information