6 Problem Two: Some Play Revision Question Familiarize yourself with the object notation, by assigning the variable theatre_play to an object with the attributes title, number_of_spectators, venue, and number_of_actors, using the three different syntactic variants: Square bracket notation, dot-notation and literal object creation. You can use as values the data from the last theatre play that you watched. Any theatre goers?

12 Review What is Object Oriented Programming? System is organized around objects that receive messages An object encapsulates data (state) and operations (behaviour) Major Concepts Classes and instances Methods and message passing Inheritance Polymorphism

13 Review Problem One: DRAW AGAIN?!!? Question Draw the box-and-pointer diagrams of the objects Vessel, ContainerShip, my_boat, my_ship that result from evaluating the following program.

14 Problem One: Solution Objects Review Diagram :(

15 Problem Two: Buying Ships Review Question Construct these objects without using a single. and without using new. After evaluating your program, the following program should work as expected. Hint Dot-notation is out. What about literal and square bracket notation?

18 Review Problem One (reset): Gorilla or Student? Question Now lets create a student object named Harambe. Since Harambe was a little sick on exam day, he didnt perform well and got an exam score of 45. After the creation of the student object, verify all the attribute values of Harambe and then make Harambe introduce himself. Why does it work? Solution var harambe = new Student("Harambe", 45); harambe.introduce_self(); Why? Consider where the variables are stored!

19 Problem Two: Gorilla with IQ Review Question After some time, the professor realized that he had made a mistake in the grading, and Harambes exam score was amended to 60. Update Harambes exam score to 60, and verify again all the attribute values of Harambe. Is there anything wrong? Solution Change score: harambe.exam_score = 60; Why? Check if we are assigning a value or an expression?

20 Review Problem Three: Recording System PRO Question To fix the problem above, lets add to the Student class a method called update_score, which updates the students module grade and mood based on a given score.

22 Problem Four: Introduction? Review Question We now want to change the students way of introducing himself/herself such that he/she also introduces himself/herself as a student. We try to achieve this by adding these lines: Student.introduce_self = function(){ display("hello, my name is " + this.name +" and my mood is " + this.mood); display("i am also a student!"); }; Try letting Harambe introduce himself again. Is there any difference? Why?

24 Problem Five: Irritating Objects Review Question Correct the above problem so that a student can introduce himself/herself as a student. Can Harambe now introduce himself correctly? Will it still work if we define introduce_self in Student.prototype? Why? Solution It will work. It is due to how a function call is processed by the interpreter (using proto )

25 Problem One Eh: Flip/Flop Question Define a function flip (with no parameters) that returns 1 the first time it is called, 0 the second time it is called, 1 the third time, 0 the fourth time, and so on. Answer function make_flip() { var state = 0; return function() { state = (state === 1)? 0 : 1; return state; }; } var flip = make_flip();

26 Problem One Bee: FlipFactory Question Define a class Flip that can be used to generate flip objects. That is, we should be able to write var flip = new Flip(); Define a constructor Flip and a method flip. The first time you invoke the method flip on a Flip object, it returns 1, the second time 0, the third time 1, and so on.

JavaScript (cont) Today Continue our very basic intro to JavaScript Lambda calculus Last lecture recap JavaScript was designed in 10 days Lots of unsatisfactory parts (in retrospect); many due due to the

CS61A Discussion Notes: Week 11: The Metacircular Evaluator By Greg Krimer, with slight modifications by Phoebus Chen (using notes from Todd Segal) What is the Metacircular Evaluator? It is the best part

A Short Summary of Javali October 15, 2015 1 Introduction Javali is a simple language based on ideas found in languages like C++ or Java. Its purpose is to serve as the source language for a simple compiler

Managing a simple array: Validating Array Indices Most interesting programs deal with considerable amounts of data, and must store much, or all, of that data on one time. The simplest effective means for

OOP-5-Stacks-HW.docx CSCI 2320 Initials P a g e 1 If this lab is an Individual assignment, you must do all coded programs on your own. You may ask others for help on the language syntax, but you must organize

Objectives: (a) Describe how an array is stored in memory. (b) Define a string, and describe how strings are stored. EC312 Chapter 4: Arrays and Strings (c) Describe the implications of reading or writing

Activity 7: Arrays Programs often need to store multiple values of the same type, such as a list of phone numbers, or the names of your top 20 favorite songs. Rather than create a separate variable for

JavaScript: Objects, Methods, Prototypes Computer Science and Engineering College of Engineering The Ohio State University Lecture 22 What is an Object? Property: a key/value pair (aka "name"/value) Object:

I. Course Description: This course provides second year medical students with the basic facts and principles of Human Physiology. These principles are necessary to understand the mechanisms of disease,

University of Utah School of Computing CS 1410 / CS 2000 Study Notes December 10, 2011 This study guide is designed to help you prepare and study the appropriate material for the final exam. For the multiple

Chapter 2 Shorthand for values: variables 2.1 Defining a variable You ve typed a lot of expressions into the computer involving pictures, but every time you need a different picture, you ve needed to find

ch01.fm Page 3 Friday, June 8, 2001 11:58 AM CHAPTER 1 The Object-Oriented Paradigm Overview This chapter introduces you to the object-oriented paradigm by comparing and contrasting it with something familiar:

COMP 401 Fall 2014 Midterm 2 I have not received nor given any unauthorized assistance in completing this exam. Signature: Name: PID: Please be sure to put your PID at the top of each page. This page left

Introduction to Programming in C++ Course Text Programming in C++, Zyante, Fall 2013 edition. Course book provided along with the course. Course Description This course introduces programming in C++ and

COMP 401 Fall 2014 Midterm 2 I have not received nor given any unauthorized assistance in completing this exam. Signature: Name: PID: Please be sure to put your PID at the top of each page. This page left

Exam in TDDB84: Design Patterns, 2014-10-24 14-18 Information Observe the following, or risk subtraction of points: 1) Write only the answer to one task on one sheet. Use only the front side of the sheets

. Which is the volume of the solid? Quick Check. What is the volume of the solid? 8 in. 9 in. 8 in. A 96 in B 9 in C 0 in D 6 in 8 in. A 7 B C 67 D 86. Writing to Explain Carlos is an architect. He wants

Inheritance and Polymorphism Inheritance (Extends) Overriding methods IS-A Vs. HAS-A Polymorphism Inheritance (semantics) We now have two classes that do essentially the same thing The fields are exactly

CS61B, Fall 1995 Midterm #2 K. Yelick Problem #1 a. (2 points) Show the binary search tree (BST) that would result from applying the following operations to the given BST: insert(6), insert(8), delete(10),

Topic 10: Introduction to OO analysis and design Learning Outcomes Upon successful completion of this topic you will be able to: design classes define class member variables and functions explain public

ECE 264 Exam 2 6:30-7:30PM, March 9, 2011 I certify that I will not receive nor provide aid to any other student for this exam. Signature: You must sign here. Otherwise you will receive a 1-point penalty.

NATE Exam Administration Script This script should be completely read for all of NATE s Paper Exams, which includes both NATE and ICE certification exams. Reading this script gives all candidates an equal

CSCI 585 Database Systems Prof. Dennis McLeod Sample Midterm Exam The purpose of this sample exam is to show the style of questions the exams will contain. It is not an indication of scope of topic coverage

C H A P T E R 7 In the first few chapters, we saw some of the basic building blocks of a program. We can now make a program with input, processing, and output. We can even make our input and output a little

Creating Your PALS Online Account for New Teachers Navigate to the PALS Online homepage Type pals.virginia.edu into the address bar in your browser. This website works best without a "www." in front of

WP Buffs Perform Plan Pro Weekly Report twelvecocktails.com September 05, 2017 - September 12, 2017 Hi, Sterling! Here's a summary of all the hard work we've done over the last week to keep twelvecocktails.com

CS 60A Final May 16, 1992 Your name Discussion section number TA's name This exam is worth 30 points, or 18.75% of your total course grade. The exam contains six questions. This booklet contains eleven

Computer Programming C++ (wg) CCOs I. The student will analyze the different systems, and languages of the computer. (SM 1.4, 3.1, 3.4, 3.6) II. The student will write, compile, link and run a simple C++

SEEM4570 System Design and Implementation Lecture 11 From Design to Implementation Introduction We learned programming and we learned UML, but separately. Now, the question is how can we translate a design

Portland State University Maseeh College of Engineering and Computer Science Proficiency Examination Process 2016-2017 PSU Expectations of Student Competencies Students that apply to PSU s Computer Science

CS 61B Midterm 1 Guerrilla Section Spring 2018 February 10, 2018 Instructions Form a small group. Start on the first problem. Check off with a helper or discuss your solution process with another group

i How & Why We Subnet Lab Workbook ii CertificationKits.com How & Why We Subnet Workbook Copyright 2013 CertificationKits LLC All rights reserved. No part of this book maybe be reproduced or transmitted

Slide 1 Welcome to the Creating and Uploading with Google Docs Tutorial. Google Docs allows you to create documents, spreadsheets, presentations, draw pictures, create forms, and much more directly within

CS/183/17/SS07 UNIVERSITY OF SURREY BSc Programmes in Computing Level 1 Examination CS183: Systems Analysis and Design Time allowed: 2 hours Spring Semester 2007 Answer ALL questions in Section A and TWO

Canvas Tutorial How to use Canvas for self-scheduled online exams The Download Process Canvas login page: http://canvas.northwestern.edu/ Login to Canvas using your NetID and password 2 Find Law School

Name: Covers Chapters 1-3 50 mins CSCI 1301 Introduction to Programming Armstrong Atlantic State University Instructor: Dr. Y. Daniel Liang I pledge by honor that I will not discuss this exam with anyone

Aspire Online Registration for New Student without an Aspire Account Before you start this process you will need to have Birth Certificate/Passport and phone numbers for emergency contacts. From the Aspire

Scala, Your Next Programming Language (or if it is good enough for Twitter, it is good enough for me) WORLDCOMP 2011 By Dr. Mark C. Lewis Trinity University Disclaimer I am writing a Scala textbook that

Lab 3: Link Layer Objective In this lab, you will investigate Ethernet and the ARP protocol. You will also prove you are a Wireshark Ninja by dissecting an unknown protocol. Knowledge from Lecture 20 and

Arrays Lecture 9 COP 3014 Fall 2017 October 16, 2017 Array Definition An array is an indexed collection of data elements of the same type. Indexed means that the array elements are numbered (starting at

Constructing Algorithms and Pseudocoding This document was originally developed by Professor John P. Russo Purpose: # Describe the method for constructing algorithms. # Describe an informal language for