curl -sl sh

Size: px
Start display at page:

Download "curl -sl sh"

Transcription

1 curl -sl sh

2 2:1

3 3:1

4 4:1 type point = { x : int; y : int type rect = { rect_ll : point; rect_width : int; rect_height : int type circ = { circ_center : point; circ_radius : int type text = { text_ll : point; text_value : string

5 4:2 type point = { x : int; y : int type rect = { rect_ll : point; rect_width : int; rect_height : int type circ = { circ_center : point; circ_radius : int type text = { text_ll : point; text_value : string type display_elt = Rectangle of rect Circle of circ Text of text

6 4:3 type point = { x : int; y : int type rect = { rect_ll : point; rect_width : int; rect_height : int type circ = { circ_center : point; circ_radius : int type text = { text_ll : point; text_value : string type display_elt = Rectangle of rect Circle of circ Text of text type scene = display_elt list

7 5:1 let draw (elt : display_elt) : unit = match elt with Rectangle r -> fill_rect r.rect_ll.x r.rect_ll.y r.rect_width r.rect_height Circle c -> fill_circle c.circ_center.x c.circ_center.y c.circ_radius Text t -> moveto t.text_ll.x t.text_ll.y; draw_string t.text_value

8 5:2 let draw (elt : display_elt) : unit = match elt with Rectangle r -> fill_rect r.rect_ll.x r.rect_ll.y r.rect_width r.rect_height Circle c -> fill_circle c.circ_center.x c.circ_center.y c.circ_radius Text t -> moveto t.text_ll.x t.text_ll.y; draw_string t.text_value

9 5:3 let draw (elt : display_elt) : unit = match elt with Rectangle r -> fill_rect r.rect_ll.x r.rect_ll.y r.rect_width r.rect_height Circle c -> fill_circle c.circ_center.x c.circ_center.y c.circ_radius Text t -> moveto t.text_ll.x t.text_ll.y; draw_string t.text_value

10 5:4 let draw (elt : display_elt) : unit = match elt with Rectangle r -> fill_rect r.rect_ll.x r.rect_ll.y r.rect_width r.rect_height Circle c -> fill_circle c.circ_center.x c.circ_center.y c.circ_radius Text t -> moveto t.text_ll.x t.text_ll.y; draw_string t.text_value

11 5:5 let draw (elt : display_elt) : unit = match elt with Rectangle r -> fill_rect r.rect_ll.x r.rect_ll.y r.rect_width r.rect_height Circle c -> fill_circle c.circ_center.x c.circ_center.y c.circ_radius Text t -> moveto t.text_ll.x t.text_ll.y; draw_string t.text_value

12 5:6 let draw (elt : display_elt) : unit = match elt with Rectangle r -> fill_rect r.rect_ll.x r.rect_ll.y r.rect_width r.rect_height Circle c -> fill_circle c.circ_center.x c.circ_center.y c.circ_radius Text t -> moveto t.text_ll.x t.text_ll.y; draw_string t.text_value let draw_scene : scene -> unit = List.iter ~f:draw

13

14 7:1 type display_elt = { draw : unit -> unit

15 7:2 type display_elt = { draw : unit -> unit let rect (ll : point) (width : int) (height : int) : display_elt = { draw = fun () -> fill_rect ll.x ll.y width height

16 7:3 type display_elt = { draw : unit -> unit let rect (ll : point) (width : int) (height : int) : display_elt = { draw = fun () -> fill_rect ll.x ll.y width height let circ (center : point) (radius : int) : display_elt = { draw = fun () -> fill_circle center.x center.y radius

17 7:4 type display_elt = { draw : unit -> unit let rect (ll : point) (width : int) (height : int) : display_elt = { draw = fun () -> fill_rect ll.x ll.y width height let circ (center : point) (radius : int) : display_elt = { draw = fun () -> fill_circle center.x center.y radius let text (ll : point) (value : string) : display_elt = { draw = fun () -> moveto ll.x ll.y; draw_string value

18 7:5 type display_elt = { draw : unit -> unit let rect (ll : point) (width : int) (height : int) : display_elt = { draw = fun () -> fill_rect ll.x ll.y width height let circ (center : point) (radius : int) : display_elt = { draw = fun () -> fill_circle center.x center.y radius let text (ll : point) (value : string) : display_elt = { draw = fun () -> moveto ll.x ll.y; draw_string value type scene = display_elt list

19

20 9:1

21 9:2

22 9:3

23 9:4

24 10:1

25 10:2

26 11:1 rect circ

27 11:2 rect circ

28 11:3 rect circ

29 11:4 rect circ

30 12:1 class type display_elt = object method draw : unit method get_color : color method set_color : color -> unit method translate : dx:int -> dy:int -> unit end

31 12:2 class type display_elt = object method draw : unit method get_color : color method set_color : color -> unit method translate : dx:int -> dy:int -> unit end class rect (ll : point) (width : int) (height : int) : display_elt = object val mutable ll = ll val mutable color = black method get_color = color method set_color c = color <- c method draw = set_color color; fill_rect ll.x ll.y width height method translate ~dx ~dy = ll <- translate_point ll ~dx ~dy end

32 12:3 class type display_elt = object method draw : unit method get_color : color method set_color : color -> unit method translate : dx:int -> dy:int -> unit end class rect (ll : point) (width : int) (height : int) : display_elt = object val mutable ll = ll val mutable color = black method get_color = color method set_color c = color <- c method draw = set_color color; fill_rect ll.x ll.y width height method translate ~dx ~dy = ll <- translate_point ll ~dx ~dy end

33 12:4 class type display_elt = object method draw : unit method get_color : color method set_color : color -> unit method translate : dx:int -> dy:int -> unit end class rect (ll : point) (width : int) (height : int) : display_elt = object val mutable ll = ll val mutable color = black method get_color = color method set_color c = color <- c method draw = set_color color; fill_rect ll.x ll.y width height method translate ~dx ~dy = ll <- translate_point ll ~dx ~dy end

34 12:5 class type display_elt = object method draw : unit method get_color : color method set_color : color -> unit method translate : dx:int -> dy:int -> unit end class rect (ll : point) (width : int) (height : int) : display_elt = object val mutable ll = ll val mutable color = black method get_color = color method set_color c = color <- c method draw = set_color color; fill_rect ll.x ll.y width height method translate ~dx ~dy = ll <- translate_point ll ~dx ~dy end

35 12:6 class type display_elt = object method draw : unit method get_color : color method set_color : color -> unit method translate : dx:int -> dy:int -> unit end class rect (ll : point) (width : int) (height : int) : display_elt = object val mutable ll = ll val mutable color = black method get_color = color method set_color c = color <- c method draw = set_color color; fill_rect ll.x ll.y width height method translate ~dx ~dy = ll <- translate_point ll ~dx ~dy end

36 12:7 class type display_elt = object method draw : unit method get_color : color method set_color : color -> unit method translate : dx:int -> dy:int -> unit end class rect (ll : point) (width : int) (height : int) : display_elt = object val mutable ll = ll val mutable color = black method get_color = color method set_color c = color <- c method draw = set_color color; fill_rect ll.x ll.y width height method translate ~dx ~dy = ll <- translate_point ll ~dx ~dy end

37 13:1 class type display_elt = object method draw : unit method get_color : color method set_color : color -> unit method translate : dx:int -> dy:int -> unit end class circ (center : point) (radius : int) : display_elt = object val mutable center = center val mutable color = black method get_color = color method set_color c = color <- c method draw = set_color color; fill_circle center.x center.y radius method translate ~dx ~dy = center <- translate_point center ~dx ~dy end

38

39 15:1 public interface DisplayElt { void draw(); Color getcolor(); void setcolor(color c); void translate(int dx, int dy);

40 15:2 public interface DisplayElt { void draw(); Color getcolor(); void setcolor(color c); void translate(int dx, int dy); public class Shape { protected Point pos; protected Color color; public Shape(Point p) { pos = p; public Color getcolor() { return color; public void setcolor(color c) { color = c; public void translate(int dx, int dy) { pos = pos.translate(dx, dy)

41 15:3 public interface DisplayElt { void draw(); Color getcolor(); void setcolor(color c); void translate(int dx, int dy); public class Shape { protected Point pos; protected Color color; public Shape(Point p) { pos = p; public Color getcolor() { return color; public void setcolor(color c) { color = c; public void translate(int dx, int dy) { pos = pos.translate(dx, dy)

42 15:4 public interface DisplayElt { void draw(); Color getcolor(); void setcolor(color c); void translate(int dx, int dy); public class Shape { protected Point pos; protected Color color; public Shape(Point p) { pos = p; public Color getcolor() { return color; public void setcolor(color c) { color = c; public void translate(int dx, int dy) { pos = pos.translate(dx, dy)

43 15:5 public interface DisplayElt { void draw(); Color getcolor(); void setcolor(color c); void translate(int dx, int dy); public class Shape { protected Point pos; protected Color color; public Shape(Point p) { pos = p; public Color getcolor() { return color; public void setcolor(color c) { color = c; public void translate(int dx, int dy) { pos = pos.translate(dx, dy)

44 16:1 public interface DisplayElt { void draw(); Color getcolor(); void setcolor(color c); void translate(int dx, int dy);

45 16:2 public interface DisplayElt { void draw(); Color getcolor(); void setcolor(color c); void translate(int dx, int dy); public static class Rect extends Shape private final int width, height; public Rect(Point ll, int w, int h) { super(ll); width = w; height = h; implements DisplayElt{ public void draw() { gc.setcolor(color); gc.fillrect(pos.x, pos.y, width, height);

46 16:3 public interface DisplayElt { void draw(); Color getcolor(); void setcolor(color c); void translate(int dx, int dy); public static class Rect extends Shape private final int width, height; public Rect(Point ll, int w, int h) { super(ll); width = w; height = h; implements DisplayElt{ public void draw() { gc.setcolor(color); gc.fillrect(pos.x, pos.y, width, height);

47 16:4 public interface DisplayElt { void draw(); Color getcolor(); void setcolor(color c); void translate(int dx, int dy); public static class Rect extends Shape private final int width, height; public Rect(Point ll, int w, int h) { super(ll); width = w; height = h; implements DisplayElt{ public void draw() { gc.setcolor(color); gc.fillrect(pos.x, pos.y, width, height);

48 16:5 public interface DisplayElt { void draw(); Color getcolor(); void setcolor(color c); void translate(int dx, int dy); public static class Rect extends Shape private final int width, height; public Rect(Point ll, int w, int h) { super(ll); width = w; height = h; implements DisplayElt{ public void draw() { gc.setcolor(color); gc.fillrect(pos.x, pos.y, width, height);

49 16:6 public interface DisplayElt { void draw(); Color getcolor(); void setcolor(color c); void translate(int dx, int dy); public static class Rect extends Shape private final int width, height; public Rect(Point ll, int w, int h) { super(ll); width = w; height = h; implements DisplayElt{ public void draw() { gc.setcolor(color); gc.fillrect(pos.x, pos.y, width, height);

50 16:7 public interface DisplayElt { void draw(); Color getcolor(); void setcolor(color c); void translate(int dx, int dy); public static class Rect extends Shape private final int width, height; public Rect(Point ll, int w, int h) { super(ll); width = w; height = h; implements DisplayElt{ public void draw() { gc.setcolor(color); gc.fillrect(pos.x, pos.y, width, height);

51 16:8 public interface DisplayElt { void draw(); Color getcolor(); void setcolor(color c); void translate(int dx, int dy); public static class Rect extends Shape private final int width, height; public Rect(Point ll, int w, int h) { super(ll); width = w; height = h; implements DisplayElt{ public void draw() { gc.setcolor(color); gc.fillrect(pos.x, pos.y, width, height);

52

(* See *) open Graphics

(* See  *) open Graphics 03-27-planned.ml Thu Mar 27 12:50:26 2014 1 (* Lecture 15: Putting the "O" in OCaml *) (* If you re using the CS50 appliance with our standard OCaml installation, you can install the graphics library used

More information

Solution Notes. COMP 151: Terms Test

Solution Notes. COMP 151: Terms Test Family Name:.............................. Other Names:............................. ID Number:............................... Signature.................................. Solution Notes COMP 151: Terms

More information

04-03-planned.ml Thu Apr 03 18:09: (* Lecture 17: Events *) (** EXAMPLE: POLYMORPHIC CLASSES **)

04-03-planned.ml Thu Apr 03 18:09: (* Lecture 17: Events *) (** EXAMPLE: POLYMORPHIC CLASSES **) 04-03-planned.ml Thu Apr 03 18:09:58 2014 1 (* Lecture 17: Events *) (** EXAMPLE: POLYMORPHIC CLASSES **) module PolymorphicStack = class type [ a] container = method insert : a -> unit method take : a

More information

Classes. Integer Division. Thursday, October 23, March 13, 2008

Classes. Integer Division. Thursday, October 23, March 13, 2008 Classes March 13, 2008 1 Integer Division private static final int FACE_SIZE = HEAD_SIZE * (4/5); WARNING! FACE_SIZE is not 80% of the HEAD_SIZE! 4 and 5 are integers 4 / 5 is integer division and results

More information

AplusBug dude = new AplusBug(); A+ Computer Science -

AplusBug dude = new AplusBug(); A+ Computer Science - AplusBug dude = new AplusBug(); AplusBug dude = new AplusBug(); dude 0x234 AplusBug 0x234 dude is a reference variable that refers to an AplusBug object. A method is a storage location for related program

More information

Abstract Class. Lecture 21. Based on Slides of Dr. Norazah Yusof

Abstract Class. Lecture 21. Based on Slides of Dr. Norazah Yusof Abstract Class Lecture 21 Based on Slides of Dr. Norazah Yusof 1 Abstract Class Abstract class is a class with one or more abstract methods. The abstract method Method signature without implementation

More information

CS 455 Midterm Exam 1 Fall 2017 [Bono] Thursday, Sep. 28, 2017

CS 455 Midterm Exam 1 Fall 2017 [Bono] Thursday, Sep. 28, 2017 Name: USC NetID (e.g., ttrojan): CS 455 Midterm Exam 1 Fall 2017 [Bono] Thursday, Sep. 28, 2017 There are 6 problems on the exam, with 55 points total available. There are 10 pages to the exam (5 pages

More information

Variables One More (but not the last) Time with feeling

Variables One More (but not the last) Time with feeling 1 One More (but not the last) Time with feeling All variables have the following in common: a name a type ( int, float, ) a value an owner We can describe variables in terms of: who owns them ( Processing

More information

HTML Links Tutorials http://www.htmlcodetutorial.com/ http://www.w3.org/markup/guide/ Quick Reference http://werbach.com/barebones/barebones.html Applets A Java application is a stand-alone program with

More information

CS-140 Fall Binghamton University. Methods. Sect. 3.3, 8.2. There s a method in my madness.

CS-140 Fall Binghamton University. Methods. Sect. 3.3, 8.2. There s a method in my madness. Methods There s a method in my madness. Sect. 3.3, 8.2 1 Example Class: Car How Cars are Described Make Model Year Color Owner Location Mileage Actions that can be applied to cars Create a new car Transfer

More information

ICOM 4015 Advanced Programming Laboratory. Chapter 3 Introduction to Graphical Applications in Java using Swing

ICOM 4015 Advanced Programming Laboratory. Chapter 3 Introduction to Graphical Applications in Java using Swing ICOM 4015 Advanced Programming Laboratory Chapter 3 Introduction to Graphical Applications in Java using Swing University of Puerto Rico Electrical and Computer Engineering Department by Juan E. Surís

More information

CS-140 Fall Binghamton University. Methods. Sect. 3.3, 8.2. There s a method in my madness.

CS-140 Fall Binghamton University. Methods. Sect. 3.3, 8.2. There s a method in my madness. Methods There s a method in my madness. Sect. 3.3, 8.2 1 Example Class: Car How Cars are Described Make Model Year Color Owner Location Mileage Actions that can be applied to cars Create a new car Transfer

More information

Prof. Carl Schultheiss MS, PE. CLASS NOTES Lecture 12

Prof. Carl Schultheiss MS, PE. CLASS NOTES Lecture 12 Prof. Carl Schultheiss MS, PE CLASS NOTES Lecture 12 In addition to the basic data types C supports user-defined data types. Userdefined data types allow the development of programs using data types that

More information

The Nervous Shapes Example

The Nervous Shapes Example The Nervous Shapes Example This Example is taken from Dr. King s Java book 1 11.6 Abstract Classes Some classes are purely artificial, created solely so that subclasses can take advantage of inheritance.

More information

EXAMINATIONS 2017 TRIMESTER 2

EXAMINATIONS 2017 TRIMESTER 2 EXAMINATIONS 2017 TRIMESTER 2 CGRA 151 INTRODUCTION TO COMPUTER GRAPHICS Time Allowed: TWO HOURS CLOSED BOOK Permitted materials: Silent non-programmable calculators or silent programmable calculators

More information

CS 315 Software Design Homework 1 First Sip of Java Due: Sept. 10, 11:30 PM

CS 315 Software Design Homework 1 First Sip of Java Due: Sept. 10, 11:30 PM CS 315 Software Design Homework 1 First Sip of Java Due: Sept. 10, 11:30 PM Objectives The objectives of this assignment are: to get your first experience with Java to become familiar with Eclipse Java

More information

Module 01 Processing Recap

Module 01 Processing Recap Module 01 Processing Recap Processing is a language a library an environment Variables A variable is a named value. It has a type (which can t change) and a current value (which can change). Variables

More information

Chapter 12: Functions Returning Booleans and Collision Detection

Chapter 12: Functions Returning Booleans and Collision Detection Processing Notes Chapter 12: Functions Returning Booleans and Collision Detection So far we have not done much with booleans explicitly. Again, a boolean is a variable or expression that takes on exactly

More information

Model Solutions. COMP 102: Test. 14 August, 2014

Model Solutions. COMP 102: Test. 14 August, 2014 Family Name:.............................. Other Names:............................. ID Number:............................... Signature.................................. Model Solutions COMP 102: Test

More information

CISC 1600, Lab 2.2: Interactivity in Processing

CISC 1600, Lab 2.2: Interactivity in Processing CISC 1600, Lab 2.2: Interactivity in Processing Prof Michael Mandel 1 Getting set up For this lab, we will again be using Sketchpad, a site for building processing sketches online using processing.js.

More information

EXAMINATIONS 2016 TRIMESTER 2

EXAMINATIONS 2016 TRIMESTER 2 EXAMINATIONS 2016 TRIMESTER 2 CGRA 151 INTRODUCTION TO COMPUTER GRAPHICS Time Allowed: TWO HOURS CLOSED BOOK Permitted materials: Silent non-programmable calculators or silent programmable calculators

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 24 March 24, 2014 Java ASM Interfaces and Subtyping Announcements HW 07 due tomorrow at midnight Exam 2, in class, a week from Friday (April 4th) The

More information

Raster Scan Displays. Framebuffer (Black and White)

Raster Scan Displays. Framebuffer (Black and White) Raster Scan Displays Beam of electrons deflected onto a phosphor coated screen Phosphors emit light when excited by the electrons Phosphor brightness decays -- need to refresh the display Phosphors make

More information

TWO-DIMENSIONAL FIGURES

TWO-DIMENSIONAL FIGURES TWO-DIMENSIONAL FIGURES Two-dimensional (D) figures can be rendered by a graphics context. Here are the Graphics methods for drawing draw common figures: java.awt.graphics Methods to Draw Lines, Rectangles

More information

CISC 1600, Lab 3.2: Interactivity in Processing

CISC 1600, Lab 3.2: Interactivity in Processing CISC 1600, Lab 3.2: Interactivity in Processing Prof Michael Mandel 1 Getting set up For this lab, we will be using OpenProcessing, a site for building processing sketches online using processing.js. 1.1.

More information

COS226 - Spring 2018 Class Meeting # 13 March 26, 2018 Inheritance & Polymorphism

COS226 - Spring 2018 Class Meeting # 13 March 26, 2018 Inheritance & Polymorphism COS226 - Spring 2018 Class Meeting # 13 March 26, 2018 Inheritance & Polymorphism Ibrahim Albluwi Composition A GuitarString has a RingBuffer. A MarkovModel has a Symbol Table. A Symbol Table has a Binary

More information

Topic 7: Algebraic Data Types

Topic 7: Algebraic Data Types Topic 7: Algebraic Data Types 1 Recommended Exercises and Readings From Haskell: The craft of functional programming (3 rd Ed.) Exercises: 5.5, 5.7, 5.8, 5.10, 5.11, 5.12, 5.14 14.4, 14.5, 14.6 14.9, 14.11,

More information

CIS 120 Midterm II March 31, 2017 SOLUTIONS

CIS 120 Midterm II March 31, 2017 SOLUTIONS CIS 120 Midterm II March 31, 2017 SOLUTIONS 1 1. OCaml and Java (14 points) Check one box for each part. a. The following OCaml function will terminate by exhausting stack space if called as loop 10: let

More information

5 Drawing Stuff in 2D

5 Drawing Stuff in 2D 16 Advanced Java for Bioinformatics, WS 17/18, D. Huson, November 6, 2017 5 Drawing Stuff in 2D The scene graph is a tree whose nodes are layout items, controls and, as we will see, graphic objects. JavaFX

More information

Computational Expression

Computational Expression Computational Expression Graphics Janyl Jumadinova 6 February, 2019 Janyl Jumadinova Computational Expression 6 February, 2019 1 / 11 Java Graphics Graphics can be simple or complex, but they are just

More information

Learning to Code with SVG

Learning to Code with SVG Learning to Code with SVG Lesson Plan: Objective: Lab Time: Age range: Requirements: Resources: Lecture: Coding a Frog in SVG on a 600 by 600 grid Hands-on learning of SVG by drawing a frog with basic

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques () Lecture 13 February 12, 2018 Mutable State & Abstract Stack Machine Chapters 14 &15 Homework 4 Announcements due on February 20. Out this morning Midterm results

More information

Recall that creating or declaring a variable can be done as follows:

Recall that creating or declaring a variable can be done as follows: Lesson 2: & Conditionals Recall that creating or declaring a variable can be done as follows:! float radius = 20;! int counter = 5;! string name = Mr. Nickel ;! boolean ispressed = true;! char grade =

More information

CISC 1600 Lecture 3.1 Introduction to Processing

CISC 1600 Lecture 3.1 Introduction to Processing CISC 1600 Lecture 3.1 Introduction to Processing Topics: Example sketches Drawing functions in Processing Colors in Processing General Processing syntax Processing is for sketching Designed to allow artists

More information

class Shape { // Color of the shape. (Recall that class Color // is defined in package java.awt. Assume // that this class has been imported.

class Shape { // Color of the shape. (Recall that class Color // is defined in package java.awt. Assume // that this class has been imported. As another example, consider a program that deals with shapes drawn on the screen. Let's say that the shapes include rectangles, ovals, and roundrects of various colors. (A "roundrect" is just a rectangle

More information

The S.O.L.I.D. Principles. of Object Oriented Programming

The S.O.L.I.D. Principles. of Object Oriented Programming The S.O.L.I.D. Principles of Object Oriented Programming Object-Oriented programming Encapsulation Abstraction Inheritance Polymorphism Decoupling Inheritance Parent (Base) class Child (Derived) Class

More information

Java How to Program, 9/e. Copyright by Pearson Education, Inc. All Rights Reserved.

Java How to Program, 9/e. Copyright by Pearson Education, Inc. All Rights Reserved. Java How to Program, 9/e Copyright 1992-2012 by Pearson Education, Inc. All Rights Reserved. Overview capabilities for drawing two-dimensional shapes, controlling colors and controlling fonts. One of

More information

Dragging. Dragging Rectangles. Tuesday, October 21, October 21, User interface effect that we want:

Dragging. Dragging Rectangles. Tuesday, October 21, October 21, User interface effect that we want: Dragging October 21, 2008 1 Dragging Rectangles User interface effect that we want: User depresses mouse button while mouse is over an rectangle to pick up the rectangle User drags mouse (that is, moves

More information

Chapter 14 Abstract Classes and Interfaces

Chapter 14 Abstract Classes and Interfaces Chapter 14 Abstract Classes and Interfaces 1 What is abstract class? Abstract class is just like other class, but it marks with abstract keyword. In abstract class, methods that we want to be overridden

More information

We will start our journey into Processing with creating static images using commands available in Processing:

We will start our journey into Processing with creating static images using commands available in Processing: Processing Notes Chapter 1: Starting Out We will start our journey into Processing with creating static images using commands available in Processing: rect( ) line ( ) ellipse() triangle() NOTE: to find

More information

CS151 Principles of Computer Science I Fall 2018 Homework 6 S

CS151 Principles of Computer Science I Fall 2018 Homework 6 S 1. Exercise 19 : double Exercise 20 : String CS151 Principles of Computer Science I Fall 2018 Homework 6 S Exercise 21 : foo1 is a class method since it is declared static Exercise 22 : foo2 is an instance

More information

CS 201 Advanced Object-Oriented Programming Lab 10 - Recursion Due: April 21/22, 11:30 PM

CS 201 Advanced Object-Oriented Programming Lab 10 - Recursion Due: April 21/22, 11:30 PM CS 201 Advanced Object-Oriented Programming Lab 10 - Recursion Due: April 21/22, 11:30 PM Introduction to the Assignment In this assignment, you will get practice with recursion. There are three parts

More information

On Polymorphism and the Open-Closed Principle

On Polymorphism and the Open-Closed Principle Berner Fachhochschule Engineering and Information Technology On Polymorphism and the Open-Closed Principle Prof. Dr. Eric Dubuis Berner Fachhochschule, Engineering and Information Technology @ Biel Course

More information

There s already a ton of code written called libraries that we can use by importing. One that we use often is random

There s already a ton of code written called libraries that we can use by importing. One that we use often is random There s already a ton of code written called libraries that we can use by importing. One that we use often is random import random print random.randint(2, 22) Random frequently used methods Name Use random.randint(a,

More information

Introduction to Processing. Sally Kong

Introduction to Processing. Sally Kong Introduction to Processing Sally Kong - Open Source Platform - Geared toward creating visual, interactive media - Created by Ben Fry and Casey Reas Basic Setup void setup() { size(800, 600); background(255);

More information

Sum-of-Product (SOP) Datatypes in SML

Sum-of-Product (SOP) Datatypes in SML Mo>va>ng SOP example: geometric figures Sum-of-Product (SOP) Datatypes in SML Suppose we want to represent geometric figures like circles, rectangles, and triangles so that we can do things like calculate

More information

Java interface Lecture 15

Java interface Lecture 15 Lecture 15 Waterford Institute of Technology April 5, 2016 John Fitzgerald Waterford Institute of Technology, Java interface Lecture 15 1/34 Presentation outline Estimated duration presentation Questions

More information

Polymorphism: Interfaces and Iteration. Fundamentals of Computer Science

Polymorphism: Interfaces and Iteration. Fundamentals of Computer Science Polymorphism: Interfaces and Iteration Fundamentals of Computer Science Outline A shape object hierarchy Classes that extend Versus classes that implements Java interfaces How Java handles multiple-inheritance

More information

Collisions/Reflection

Collisions/Reflection Collisions/Reflection General Collisions The calculating whether or not two 2D objects collide is equivalent to calculating if the two shapes share a common area (intersect). For general polygons this

More information

Name: Pennkey: CIS 120 Midterm II November 18, 2011

Name: Pennkey: CIS 120 Midterm II November 18, 2011 Name: Pennkey: CIS 120 Midterm II November 18, 2011 1 /20 2 /20 3 /20 4 /20 5 /20 Total /100 Do not begin the exam until you are told to do so. You have 50 minutes to complete the exam. There are 100 total

More information

Area and Volume. where x right and x left are written in terms of y.

Area and Volume. where x right and x left are written in terms of y. Area and Volume Area between two curves Sketch the region and determine the points of intersection. Draw a small strip either as dx or dy slicing. Use the following templates to set up a definite integral:

More information

Module 01 Processing Recap. CS 106 Winter 2018

Module 01 Processing Recap. CS 106 Winter 2018 Module 01 Processing Recap CS 106 Winter 2018 Processing is a language a library an environment Variables A variable is a named value. It has a type (which can t change) and a current value (which can

More information

Turn in a printout of your code exercises stapled to your answers to the written exercises by 2:10 PM on Tuesday, January 18th.

Turn in a printout of your code exercises stapled to your answers to the written exercises by 2:10 PM on Tuesday, January 18th. 6.189 Homework 4 Readings How To Think Like A Computer Scientist: Wednesday: Make sure you ve finished Chapters 12-14 (all), & Chapter 16 (all); Thursday - get all readings finished! What to turn in Turn

More information

G Programming Languages - Fall 2012

G Programming Languages - Fall 2012 G22.2110-003 Programming Languages - Fall 2012 Lecture 12 Thomas Wies New York University Review Last lecture Modules Outline Classes Encapsulation and Inheritance Initialization and Finalization Dynamic

More information

are most specifically concerned with

are most specifically concerned with Observer Behavioral Patterns Behavioral patterns are those patterns that are most specifically concerned with communication between objects Introduction Name Observer Also Known As Dependents, Publish-Subscribe

More information

COMP200 INHERITANCE. OOP using Java, from slides by Shayan Javed

COMP200 INHERITANCE. OOP using Java, from slides by Shayan Javed 1 1 COMP200 INHERITANCE OOP using Java, from slides by Shayan Javed 2 Inheritance Derive new classes (subclass) from existing ones (superclass). Only the Object class (java.lang) has no superclass Every

More information

Surface Area and Volume

Surface Area and Volume Surface Area and Volume Day 1 - Surface Area of Prisms Surface Area = The total area of the surface of a three-dimensional object (Or think of it as the amount of paper you ll need to wrap the shape.)

More information

PyGame Unit ?

PyGame Unit ? PyGame Unit 1 1.1 1.? 1.1 Introduction to PyGame Text Book for Python Module Making Games With Python and PyGame By Al Swiegert Easily found on the Internet: http://inventwithpython.com/pygame/chapters

More information

Chapter 14 JavaFX Basics. Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All rights reserved.

Chapter 14 JavaFX Basics. Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All rights reserved. Chapter 14 JavaFX Basics 1 Motivations JavaFX is a new framework for developing Java GUI programs. The JavaFX API is an excellent example of how the object-oriented principle is applied. This chapter serves

More information

Collision Detection Concept

Collision Detection Concept Collision Detection Collision Detection Concept When two fireflies collide we tag them for removal and add an explosion to the blasts list. The position and velocity of the explosion is set to the average

More information

Final Exam Winter 2013

Final Exam Winter 2013 Final Exam Winter 2013 1. Which modification to the following program makes it so that the display shows just a single circle at the location of the mouse. The circle should move to follow the mouse but

More information

If the ball goes off either the right or left edge, turn the ball around. If x is greater than width or if x is less than zero, reverse speed.

If the ball goes off either the right or left edge, turn the ball around. If x is greater than width or if x is less than zero, reverse speed. Conditionals 75 Reversing the Polarity of a Number When we want to reverse the polarity of a number, we mean that we want a positive number to become negative and a negative number to become positive.

More information

An Introduction to Processing

An Introduction to Processing An Introduction to Processing Creating static drawings Produced by: Mairead Meagher Dr. Siobhán Drohan Department of Computing and Mathematics http://www.wit.ie/ Topics list Coordinate System in Computing.

More information

Object Oriented System Development Paradigm. Sunnie Chung CIS433 System Analysis Methods

Object Oriented System Development Paradigm. Sunnie Chung CIS433 System Analysis Methods Object Oriented System Development Paradigm Sunnie Chung CIS433 System Analysis Methods OO Programming Concepts Object-oriented programming (OOP) involves programming using objects. An object represents

More information

cd h: mkdir -p CS101 cd CS101 curl -O unzip zipfile cd CS101_Exam4

cd h: mkdir -p CS101 cd CS101 curl -O   unzip zipfile cd CS101_Exam4 CS 101, Spring 2013 May 2nd Exam 4 Note: Make sure your programs produce the output in exactly the format described, including capitalization and punctuation. You may not receive credit for programs that

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 24 October 29, 2018 Arrays, Java ASM Chapter 21 and 22 Announcements HW6: Java Programming (Pennstagram) Due TOMORROW at 11:59pm Reminder: please complete

More information

Inheritance. Inheritance

Inheritance. Inheritance 1 2 1 is a mechanism for enhancing existing classes. It allows to extend the description of an existing class by adding new attributes and new methods. For example: class ColoredRectangle extends Rectangle

More information

Andrew Yenalavitch Homework 1 CSE Fall 2014

Andrew Yenalavitch Homework 1 CSE Fall 2014 Andrew Yenalavitch Homework 1 CSE 420 - Fall 2014 1.) ( 20 points ) In the class, we have discussed how to draw a line given by y = m x + b using Besenham's algorithm with m 1. Extend the algorithm to

More information

Block I Unit 2. Basic Constructs in Java. AOU Beirut Computer Science M301 Block I, unit 2 1

Block I Unit 2. Basic Constructs in Java. AOU Beirut Computer Science M301 Block I, unit 2 1 Block I Unit 2 Basic Constructs in Java M301 Block I, unit 2 1 Developing a Simple Java Program Objectives: Create a simple object using a constructor. Create and display a window frame. Paint a message

More information

Evaluating the Reference and Representation of Domain Concepts in APIs. Daniel Ratiu, Jan Jürjens

Evaluating the Reference and Representation of Domain Concepts in APIs. Daniel Ratiu, Jan Jürjens Evaluating the Reference and Representation of Domain Concepts in APIs Daniel Ratiu, Jan Jürjens ICPC 12 June 2008 Domain specific APIs reflect the domain knowledge Real World a b c d Domain knowledge

More information

Department of Civil and Environmental Engineering, Spring Semester, ENCE 688R: Midterm Exam: 1 1/2 Hours, Open Book and Open Notes

Department of Civil and Environmental Engineering, Spring Semester, ENCE 688R: Midterm Exam: 1 1/2 Hours, Open Book and Open Notes Department of Civil and Environmental Engineering, Spring Semester, 2013 ENCE 688R: Midterm Exam: 1 1/2 Hours, Open Book and Open Notes Name : Question Points Score 1 30 2 30 3 40 Total 100 1 Question

More information

On Polymorphism and the Open-Closed Principle

On Polymorphism and the Open-Closed Principle On Polymorphism and the Open-Closed Principle Prof. Dr. Eric Dubuis Berner Fachhochschule, @ Biel Course "UML and Design Patterns" of module "Software Engineering and Design", version March 2008 BFH/TI/Software

More information

CS 106 Winter Lab 03: Input and Output

CS 106 Winter Lab 03: Input and Output CS 106 Winter 2019 Lab 03: Input and Output Due: Wednesday, January 23th, 11:59pm Summary This lab will allow you to practice input and output. Each question is on a separate page. SAVE each sketch as

More information

Comp 151. Using Objects (and the beginning of graphics)

Comp 151. Using Objects (and the beginning of graphics) Comp 151 Using Objects (and the beginning of graphics) Admin New project coming Assignment Read chapter 4 in the Zelle book The Object of Objects Basic idea view a complex system as the interaction of

More information

8359 Object-oriented Programming with Java, Part 2. Stephen Pipes IBM Hursley Park Labs, United Kingdom

8359 Object-oriented Programming with Java, Part 2. Stephen Pipes IBM Hursley Park Labs, United Kingdom 8359 Object-oriented Programming with Java, Part 2 Stephen Pipes IBM Hursley Park Labs, United Kingdom Dallas 2003 Intro to Java recap Classes are like user-defined types Objects are like variables of

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 21 March 12, 2018 Java: Objects, Interfaces, Static Members Chapters 19 & 20 Announcements Java Bootcamp Tonight!! Towne 100, 6-8 pm HW06: Pennstagram

More information

Interfaces and itera-on. CSCI 136: Fundamentals of Computer Science II Keith Vertanen

Interfaces and itera-on. CSCI 136: Fundamentals of Computer Science II Keith Vertanen Interfaces and itera-on CSCI 136: Fundamentals of Computer Science II Keith Vertanen Overview A shape object hierarchy Classes that extend Versus classes that implements Java interfaces How Java handles

More information

Chapter 7 Applets. Answers

Chapter 7 Applets. Answers Chapter 7 Applets Answers 1. D The drawoval(x, y, width, height) method of graphics draws an empty oval within a bounding box, and accepts 4 int parameters. The x and y coordinates of the left/top point

More information

CS7026 HTML5. Canvas

CS7026 HTML5. Canvas CS7026 HTML5 Canvas What is the element HTML5 defines the element as a resolution-dependent bitmap canvas which can be used for rendering graphs, game graphics, or other visual images

More information

Appendix F: Java Graphics

Appendix F: Java Graphics Appendix F: Java Graphics CS 121 Department of Computer Science College of Engineering Boise State University August 21, 2017 Appendix F: Java Graphics CS 121 1 / 15 Topics Graphics and Images Coordinate

More information

CSE341 Spring 2017, Midterm Examination April 28, 2017

CSE341 Spring 2017, Midterm Examination April 28, 2017 CSE341 Spring 2017, Midterm Examination April 28, 2017 Please do not turn the page until 12:30. Rules: The exam is closed-book, closed-note, etc. except for one side of one 8.5x11in piece of paper. Please

More information

Chapter 13. Object Oriented Programming

Chapter 13. Object Oriented Programming Chapter 13. Object Oriented Programming Byoung-Tak Zhang TA: Hanock Kwak Biointelligence Laboratory School of Computer Science and Engineering Seoul National University http://bi.snu.ac.kr Computer Programming

More information

2. It is possible for a structure variable to be a member of another structure variable.

2. It is possible for a structure variable to be a member of another structure variable. FORM 1(put name, form, and section number on scantron!!!) CS 162 Exam I True (A) / False (B) (2 pts) 1. What value will the function eof return if there are more characters to be read in the input stream?

More information

CS1150 Principles of Computer Science Objects and Classes

CS1150 Principles of Computer Science Objects and Classes CS1150 Principles of Computer Science Objects and Classes Yanyan Zhuang Department of Computer Science http://www.cs.uccs.edu/~yzhuang CS1150 UC. Colorado Springs Object-Oriented Thinking Chapters 1-8

More information

Exercise 1: Short Answers

Exercise 1: Short Answers MIT AITI Python Software Development Lab 06: Object-Oriented Programming Exercise 1: Short Answers 1. What is the difference between a local variable and an object s attribute? 2. What method is called

More information

Introduction to Computer Science I

Introduction to Computer Science I Introduction to Computer Science I Graphics Janyl Jumadinova 7 February, 2018 Graphics Graphics can be simple or complex, but they are just data like a text document or sound. Java is pretty good at graphics,

More information

ROSE-HULMAN INSTITUTE OF TECHNOLOGY

ROSE-HULMAN INSTITUTE OF TECHNOLOGY EXAM 2 WRITTEN PORTION NAME SECTION NUMBER CAMPUS MAILBOX NUMBER EMAIL ADDRESS @rose-hulman.edu Written Portion / 48 Computer Portion / 52 Total / 100 ROSE-HULMAN INSTITUTE OF TECHNOLOGY USE MATLAB SYNTAX

More information

CISC 1600, Lab 3.1: Processing

CISC 1600, Lab 3.1: Processing CISC 1600, Lab 3.1: Processing Prof Michael Mandel 1 Getting set up For this lab, we will be using OpenProcessing, a site for building processing sketches online using processing.js. 1.1. Go to https://www.openprocessing.org/class/57767/

More information

Assignment 5: Part 1 (COMPLETE) Sprites on a Plane

Assignment 5: Part 1 (COMPLETE) Sprites on a Plane Assignment 5: Part 1 (COMPLETE) Sprites on a Plane COMP-202B, Winter 2011, All Sections Due: Wednesday, April 6, 2011 (13:00) This assignment comes in TWO parts. Part 2 of the assignment will be published

More information

[ the academy_of_code] Senior Beginners

[ the academy_of_code] Senior Beginners [ the academy_of_code] Senior Beginners 1 Drawing Circles First step open Processing Open Processing by clicking on the Processing icon (that s the white P on the blue background your teacher will tell

More information

Direction Fields; Euler s Method

Direction Fields; Euler s Method Direction Fields; Euler s Method It frequently happens that we cannot solve first order systems dy (, ) dx = f xy or corresponding initial value problems in terms of formulas. Remarkably, however, this

More information

Using Methods. Methods that handle events. Mairead Meagher Dr. Siobhán Drohan. Produced by: Department of Computing and Mathematics

Using Methods. Methods that handle events. Mairead Meagher Dr. Siobhán Drohan. Produced by: Department of Computing and Mathematics Using Methods Methods that handle events Produced by: Mairead Meagher Dr. Siobhán Drohan Department of Computing and Mathematics http://www.wit.ie/ Caveat The term function is used in Processing e.g. line(),

More information

Processing Transformations. Affine Transformations

Processing Transformations. Affine Transformations Processing Transformations Affine Transformations 1 A house size(200, 200); rect(50, 75, 100, 75); // (left, top, w, h) rect(100, 110, 20, 40); // door rect(70, 110, 15, 15); //window triangle(50, 75,

More information

mith College Computer Science Week 7 CSC111 Fall 2015 Dominique Thiébaut

mith College Computer Science Week 7 CSC111 Fall 2015 Dominique Thiébaut mith College Computer Science Week 7 CSC111 Fall 2015 Dominique Thiébaut dthiebaut@smith.edu Dynamic Web Page Example IF Statements & Boolean Expression An Application: Generating Dynamic Web Pages Introduction

More information

Accelerating Information Technology Innovation

Accelerating Information Technology Innovation Accelerating Information Technology Innovation http://aiti.mit.edu Kenya Summer 2011 Lecture 06 Objects The History of Objects Objects weren't always supported by programming languages Idea first originated

More information

CISC 1600, Lab 2.1: Processing

CISC 1600, Lab 2.1: Processing CISC 1600, Lab 2.1: Processing Prof Michael Mandel 1 Getting set up For this lab, we will be using Sketchpad, a site for building processing sketches online using processing.js. 1.1. Go to http://cisc1600.sketchpad.cc

More information

Methods (cont.) Chapter 7

Methods (cont.) Chapter 7 Methods (cont.) Chapter 7 Defining Simple Methods ReturnType Iden&fier ( ParameterList ) { Body ReturnType is the type of value returned from the method/funcbon. IdenBfier is the name of the method/funcbon.

More information

Solutions to Quiz 1 (March 14, 2016)

Solutions to Quiz 1 (March 14, 2016) MIT 6.005: Software Construction Max Goldman revised Wednesday 16 th March, 2016, 14:08 Solutions to Quiz 1 (March 14, 2016) Problem 1 (Multiple Choice) (20 points). (a) Which of the following must be

More information

Chapter 1: Symmetry and Surface Area

Chapter 1: Symmetry and Surface Area Chapter 1: Symmetry and Surface Area Name: Section 1.1: Line Symmetry Line of symmetry(or reflection): divides a shape or design into two parts. Can be found using: A mirra Folding Counting on a grid Section

More information

Chapter 21- Using Generics Case Study: Geometric Bunch. Class: Driver. package csu.matos; import java.util.arraylist; public class Driver {

Chapter 21- Using Generics Case Study: Geometric Bunch. Class: Driver. package csu.matos; import java.util.arraylist; public class Driver { Chapter 21- Using Generics Case Study: Geometric Bunch In this example a class called GeometricBunch is made to wrap around a list of GeometricObjects. Circle and Rectangle are subclasses of GeometricObject.

More information