Review: Using Imported Code. What About the DrawingGizmo? Review: Classes and Object Instances. DrawingGizmo pencil; pencil = new DrawingGizmo();

Size: px
Start display at page:

Download "Review: Using Imported Code. What About the DrawingGizmo? Review: Classes and Object Instances. DrawingGizmo pencil; pencil = new DrawingGizmo();"

Transcription

1 Review: Using Imported Code Class #06: Objects, Memory, & Program Traces Software Engineering I (CS 120): M. Allen, 30 Jan ; = new ();.setbackground( java.awt.color.blue );.setforeground( java.awt.color.yellow );.turnby( 90 );.turnby( 90 );.turnby( 90 ); import java.awt.color; ; = new (); This adds the import command to the class, and now we don t have to use the full address for our colors These programs produce exactly the same result on-screen when they run.setbackground( Color.blue );.setforeground( Color.yellow );.turnby( 90 );.turnby( 90 );.turnby( 90 ); Tuesday, 30 Jan Software Design I (CS 120) 2 What About the? If we want to use built-in Java classes like Color, we need to either refer to their full class address or import For classes that aren t built in to the language, there is another simple option: put all the class files into the same source directory (folder) When we run our program, the JVM will allow us to use any class of object that we address, import, or that it can find along-side the source code for the main() method Review: Classes and Object Instances cil; cil = new (); We are working with both a class () and an object (actual code and data saved in memory, to which the name cil refers) We call the object an instance of the class Within a single program we can have more than one instance of a single class (or type of object) Each instance will be declared and instantiated separately, using distinct names Tuesday, 30 Jan Software Design I (CS 120) 3 Tuesday, 30 Jan Software Design I (CS 120) 4 1

2 Review: Creating an Object Often, we declare and instantiate objects separately, using two distinct Java commands: cil; cil = new (); Often, however, we do this together, in a single line: cil = new (); Using Multiple Objects ; = new (); cil = new ();.turnclockwise;.moveforward; cil.turncounterclockwise; cil.moveforward; One object is declared and instantiated (separately) Second object is declared and instantiated (all at once) Each object has its methods run separately, using its own unique identifier (name) Within a single code block, which approach we choose is often optional, since both do the same thing We will later learn about cases where this is not true Our code doesn t always need to use a single object It may be convenient (or necessary) to use multiple objects of the same (or different) type Tuesday, 30 Jan Software Design I (CS 120) 5 Tuesday, 30 Jan Software Design I (CS 120) 6 Review: What a Declaration Means A variable declaration tells the JVM/CPU to create a new identifier (name) in its memory-space Note: Eventually, we will want the variable to be the name of an actual object in some memory location. At first, however, the variable points to no actual memory location. (No memory has been set aside for an object yet, just the name.) The variable has a null reference. ; Memory null Tuesday, 30 Jan Software Design I (CS 120) 7 What Instantiation Means A variable instantiation tells the JVM/CPU to: 1. Go to variable (in memory), and find another empty location in memory for it to point to (where we will store the actual object) 2. Now, create a new object and fill up the newly made slot in memory with the required data 3. Point the variable that memory location, so you can find the object later (by storing the address of the object) NOTE: to help make sure our code is free of bugs, the compiler will check that the type of object we are creating agrees with the type of variable that we declared. Here, e.g., has type. = new (); Space for Memory Tuesday, 30 Jan Software Design I (CS 120) 8 2

3 The Importance of Initialization Variable Assignment Once we have actually instantiated an object of type, we can do things with it by making method calls What haps when we try to call methods on objects that do not exist yet? The code at right will not compile! ;.moveforward(); Error: is never instantiated, but a method is called on it! Giving a variable an actual value for the first time is called initialization Once we declare and instantiate a variable, we can change its value This is called variable assignment, and has the basic syntax: objectname1 = objectname2; = new (); cil; In Java this is read a very specific way: the identifier on the left now points to whatever object is given by the expression on the right When we are dealing with objects that are instances of a class (as in this example code), this moves the reference of identifier objectname1 It now points to the same memory location as objectname2 Tuesday, 30 Jan Software Design I (CS 120) 9 Tuesday, 30 Jan Software Design I (CS 120) 10 What Assignment Means A variable assignment tells the JVM/CPU: 1. Take the name on the left 2. Change what it refers to so that it is now the same as thing named on the right = cil; cil Variable Assignment This will all work just fine, as long as objectname1 and objectname2 are both variables of the same type (that is, their classes must agree with one another): = new (); cil; Question: what haps to the original object that used to name? Answer: it is orphaned, and no longer exists for use in our program Space for Space for If we try to do this with types that don t agree, the code will not compile at all: = new (); Color col = java.awt.color.blue; = col; // compiler error!! Tuesday, 30 Jan Software Design I (CS 120) 11 Tuesday, 30 Jan Software Design I (CS 120) 12 3

4 Variables and Their Objects When we properly instantiate an object: ; = new (); The variable name ( ) is bound to its object Each variable can only be bound to one object at a time Before the initialization on the 2 nd line of code above, the variable is bound to no object (it is null) We can also un-bind a variable so it points at no object: The that used to be bound is now an orphan Compilation Errors and Runtime Errors Many of the mistakes a coder makes will be caught when they try to compile their code, before it can ever be run Bad syntax (missing semicolons, etc.) Type errors (the wrong input parameter for a method, etc.) Even more complex things However, some errors cannot be caught at compile time Some code will compile, but then fail when it actually runs These are called runtime errors (or runtime exceptions) The Java environment (JVM) will try to signal what kind of runtime error we have, using an exception message Tuesday, 30 Jan Software Design I (CS 120) 13 Tuesday, 30 Jan Software Design I (CS 120) 14 Anatomy of a Runtime Error Lines starting with at tell us where the error was made Look for your file names and line numbers In Eclipse, you can click on line number to go there in the code These error messages can be quite complex! They are meant to be helpful, however. The first line tells us what sort of error we have made This is a common type: Null Pointer Exception Tracing Objects, cil, ; = new ();.moveforward();.turnclockwise(); cil = new (); = cil; It is often useful to keep track of the objects that are bound to variables This helps in figuring out what some code does, and in de-bugging code that is not working properly If you start getting a lot of Null Pointer errors, for example, you may find doing a program trace can be very helpful! Tuesday, 30 Jan Software Design I (CS 120) 15 Tuesday, 30 Jan Software Design I (CS 120) 16 4

5 Tracing Objects with Object Diagrams (1) Tracing Objects with Object Diagrams (2), cil, ; = new (); Note:.moveForward(); to save typing, Java allows us.turnclockwise(); to declare multiple variables of cil = new (); the same type on one single line. The syntax is the basically same, but we can have more than one variable = cil; name (separated by commas) after the single variable type. cil, cil, ; = new ();.moveforward();.turnclockwise(); cil = new (); = cil; cil Tuesday, 30 Jan Software Design I (CS 120) 17 Tuesday, 30 Jan Software Design I (CS 120) 18 Tracing Objects with Object Diagrams (3), cil, ; = new ();.moveforward();.turnclockwise(); cil = new (); = cil; cil Tracing Objects with Object Diagrams (4), cil, ; = new ();.moveforward();.turnclockwise(); cil = new (); = cil; cil Tuesday, 30 Jan Software Design I (CS 120) 19 Tuesday, 30 Jan Software Design I (CS 120) 20 5

6 Tracing Objects with Object Diagrams (5) Tracing Objects with Object Diagrams (6), cil, ; = new ();, cil, ; = new ();.moveforward();.moveforward();.turnclockwise(); cil = new (); cil.turnclockwise(); cil = new (); cil = cil; = cil; Tuesday, 30 Jan Software Design I (CS 120) 21 Tuesday, 30 Jan Software Design I (CS 120) 22 Reminder: Orphans are Unavailable Forever After the first object is let go, so no variable name is bound to it, we cannot ever use it again This allows the JVM to free up some memory space, which can be useful in large, complex programs Don t do it by accident! cil = new (); cil = new (); = cil; This Week & Next Meetings this week: Monday Thursday: regular classroom Friday: in the CS Lab (16 Wing) Homework 01: Groundhog image Friday, 02 Feb., 5:00 PM, D2L Reading assignment: Chapter 3, sections 1 10 Next Monday, 05 Feb., by start of class Quiz 01: Covers lectures (all on Notes page) Monday, 05 Feb. (end of class) Office Hours: Wing 210 Monday/Wednesday/Friday, 10:00 AM 11:00 AM Tuesday/Thursday, 1:30 PM 3:00 PM Tuesday, 30 Jan Software Design I (CS 120) 23 Tuesday, 30 Jan Software Design I (CS 120) 24 6

Review: Classes and Object Instances. Review: Creating an Object. Using Multiple Objects. DrawingGizmo pencil; pencil = new DrawingGizmo();

Review: Classes and Object Instances. Review: Creating an Object. Using Multiple Objects. DrawingGizmo pencil; pencil = new DrawingGizmo(); Review: Classes and Object Instances ; = new (); Class #05: Objects, Memory, & Program Traces Software Engineering I (CS 120): M. Allen, 12/13 Sept. 17 We are working with both a class () and an object

More information

} Each object in a Java program has an identifier (name) } This includes:

} Each object in a Java program has an identifier (name) } This includes: Class #05: More about Objects and Methods Software Design I (CS 120): M. Allen, 11 Sept. 2018 Important Java Syntax I: Identifiers Each object in a Java program has an identifier (name) This includes:

More information

} Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = / 2; 3. int x = 5 / ; 4. double x = 5 / 2.

} Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = / 2; 3. int x = 5 / ; 4. double x = 5 / 2. Class #10: Understanding Primitives and Assignments Software Design I (CS 120): M. Allen, 19 Sep. 18 Java Arithmetic } Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = 2 + 5 / 2; 3.

More information

Two Types of Types. Primitive Types in Java. Using Primitive Variables. Class #07: Java Primitives. Integer types.

Two Types of Types. Primitive Types in Java. Using Primitive Variables. Class #07: Java Primitives. Integer types. Class #07: Java Primitives Software Design I (CS 120): M. Allen, 13 Sep. 2018 Two Types of Types So far, we have mainly been dealing with objects, like DrawingGizmo, Window, Triangle, that are: 1. Specified

More information

Review: Object Diagrams for Inheritance. Type Conformance. Inheritance Structures. Car. Vehicle. Truck. Vehicle. conforms to Object

Review: Object Diagrams for Inheritance. Type Conformance. Inheritance Structures. Car. Vehicle. Truck. Vehicle. conforms to Object Review: Diagrams for Inheritance - String makemodel - int mileage + (String, int) Class #3: Inheritance & Polymorphism Software Design II (CS 220): M. Allen, 25 Jan. 18 + (String, int) + void

More information

Searching for Information. A Simple Method for Searching. Simple Searching. Class #21: Searching/Sorting I

Searching for Information. A Simple Method for Searching. Simple Searching. Class #21: Searching/Sorting I Class #21: Searching/Sorting I Software Design II (CS 220): M. Allen, 26 Feb. 18 Searching for Information Many applications involve finding pieces of information Finding a book in a library or store catalogue

More information

Converting Collections to Arrays. A Bad Approach to Array Conversion. A Better Approach to Array Conversion. public Object[] toarray();

Converting Collections to Arrays. A Bad Approach to Array Conversion. A Better Approach to Array Conversion. public Object[] toarray(); Converting Collections to Arrays Every Java collection can be converted to an array This is part of the basic Collection interface The most elementary form of this method produces an array of base-type

More information

Basic Class Diagrams. Class Diagrams, cont d. Class Diagrams, cont d. Car. Car. Car. What does the minus sign here mean?

Basic Class Diagrams. Class Diagrams, cont d. Class Diagrams, cont d. Car. Car. Car. What does the minus sign here mean? Class #02: Inheritance and Object-Oriented Design Software Design II (CS 220): M. Allen, 23 Jan. 18 Basic Class Diagrams Describes a class and how it can be used properly Sketch of properties and behaviors

More information

Announcements - Grades UBLearns grades just updated Monday, March 28 th (11:00am). Please check grades.

Announcements - Grades UBLearns grades just updated Monday, March 28 th (11:00am). Please check grades. CSE 113 A March 28 April 1, 2011 Announcements - Grades UBLearns grades just updated Monday, March 28 th (11:00am). Please check grades. If an EXAM grade is incorrect, you need to bring the exam to me

More information

C++ for Java Programmers

C++ for Java Programmers Basics all Finished! Everything we have covered so far: Lecture 5 Operators Variables Arrays Null Terminated Strings Structs Functions 1 2 45 mins of pure fun Introduction Today: Pointers Pointers Even

More information

CS 201 Advanced Object-Oriented Programming Lab 6 - Sudoku, Part 2 Due: March 10/11, 11:30 PM

CS 201 Advanced Object-Oriented Programming Lab 6 - Sudoku, Part 2 Due: March 10/11, 11:30 PM CS 201 Advanced Object-Oriented Programming Lab 6 - Sudoku, Part 2 Due: March 10/11, 11:30 PM Introduction to the Assignment In this lab, you will finish the program to allow a user to solve Sudoku puzzles.

More information

Name: 1) 2) 3) 4) 5) Learning Objectives (Milestones): 1. Create and use JUnit tests to debug a sample Java program.

Name: 1) 2) 3) 4) 5) Learning Objectives (Milestones): 1. Create and use JUnit tests to debug a sample Java program. Lab Exercise #2 junit Testing with Eclipse CS 2334, Spring 2014 Due by: Friday, January 24, 2014, 4:30 pm CST This lab is a group exercise. Students must complete this assignment with at least one partner.

More information

QUIZ. What is wrong with this code that uses default arguments?

QUIZ. What is wrong with this code that uses default arguments? QUIZ What is wrong with this code that uses default arguments? Solution The value of the default argument should be placed in either declaration or definition, not both! QUIZ What is wrong with this code

More information

Decisions, Decisions, Decisions. GEEN163 Introduction to Computer Programming

Decisions, Decisions, Decisions. GEEN163 Introduction to Computer Programming Decisions, Decisions, Decisions GEEN163 Introduction to Computer Programming You ve got to be very careful if you don t know where you are going, because you might not get there. Yogi Berra TuringsCraft

More information

Cadence Capture and PSpice Tutorial

Cadence Capture and PSpice Tutorial Cadence Capture and PSpice Tutorial This tutorial is intended to give you needed elements for using Cadence Capture and PSpice to design and simulate the digital logic circuit in Homework 2A, Problem 2.

More information

CS 31 Discussion 1A, Week 1. Zengwen Yuan (zyuan [at] cs.ucla.edu) Humanities A65, Friday 10:00 11:50

CS 31 Discussion 1A, Week 1. Zengwen Yuan (zyuan [at] cs.ucla.edu) Humanities A65, Friday 10:00 11:50 CS 31 Discussion 1A, Week 1 Zengwen Yuan (zyuan [at] cs.ucla.edu) Humanities A65, Friday 10:00 11:50 TA Zengwen Yuan ( zyuan [at] cs.ucla.edu ) Discussion session (1A): Humanities A65 Friday 10:00 11:50

More information

Lab 1: Introduction to Java

Lab 1: Introduction to Java Lab 1: Introduction to Java Welcome to the first CS15 lab! In the reading, we went over objects, methods, parameters and how to put all of these things together into Java classes. It's perfectly okay if

More information

COMP 105 Homework: Type Systems

COMP 105 Homework: Type Systems Due Tuesday, March 29, at 11:59 PM (updated) The purpose of this assignment is to help you learn about type systems. Setup Make a clone of the book code: git clone linux.cs.tufts.edu:/comp/105/build-prove-compare

More information

Designing Loops and General Debug Pre-Defined Functions in C++ CS 16: Solving Problems with Computers I Lecture #6

Designing Loops and General Debug Pre-Defined Functions in C++ CS 16: Solving Problems with Computers I Lecture #6 Designing Loops and General Debug Pre-Defined Functions in C++ CS 16: Solving Problems with Computers I Lecture #6 Ziad Matni Dept. of Computer Science, UCSB Announcements Homework #5 due today Lab #3

More information

Project 1 Balanced binary

Project 1 Balanced binary CMSC262 DS/Alg Applied Blaheta Project 1 Balanced binary Due: 7 September 2017 You saw basic binary search trees in 162, and may remember that their weakness is that in the worst case they behave like

More information

Administration. Classes. Objects Part II. Agenda. Review: Object References. Object Aliases. CS 99 Summer 2000 Michael Clarkson Lecture 7

Administration. 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 information

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit.

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit. Com S 227 Fall 2017 Miniassignment 1 50 points Due Date: Monday, October 16, 11:59 pm (midnight) Late deadline (25% penalty): Tuesday, October 17, 11:59 pm General information This assignment is to be

More information

CS61C Machine Structures. Lecture 3 Introduction to the C Programming Language. 1/23/2006 John Wawrzynek. www-inst.eecs.berkeley.

CS61C Machine Structures. Lecture 3 Introduction to the C Programming Language. 1/23/2006 John Wawrzynek. www-inst.eecs.berkeley. CS61C Machine Structures Lecture 3 Introduction to the C Programming Language 1/23/2006 John Wawrzynek (www.cs.berkeley.edu/~johnw) www-inst.eecs.berkeley.edu/~cs61c/ CS 61C L03 Introduction to C (1) Administrivia

More information

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG 1 Notice Reading Assignment Chapter 1: Introduction to Java Programming Homework 1 It is due this coming Sunday

More information

Administration. Objects and Arrays. Objects. Agenda. What is an Object? What is a Class?

Administration. Objects and Arrays. Objects. Agenda. What is an Object? What is a Class? Administration Objects and Arrays CS 99 Summer 2000 Michael Clarkson Lecture 6 Read clarified grading policies Lab 6 due tomorrow Submit.java files in a folder named Lab6 Lab 7 Posted today Upson Lab closed

More information

CMSC 201 Fall 2016 Lab 09 Advanced Debugging

CMSC 201 Fall 2016 Lab 09 Advanced Debugging CMSC 201 Fall 2016 Lab 09 Advanced Debugging Assignment: Lab 09 Advanced Debugging Due Date: During discussion Value: 10 points Part 1: Introduction to Errors Throughout this semester, we have been working

More information

CMPE 152 Compiler Design

CMPE 152 Compiler Design San José State University Department of Computer Engineering CMPE 152 Compiler Design Section 1 (Class) Sections 2 and 3 (Labs) Spring 2019 Course and Contact Information Instructor: Ron Mak Office Location:

More information

CSCI0330 Intro Computer Systems Doeppner. Lab 02 - Tools Lab. Due: Sunday, September 23, 2018 at 6:00 PM. 1 Introduction 0.

CSCI0330 Intro Computer Systems Doeppner. Lab 02 - Tools Lab. Due: Sunday, September 23, 2018 at 6:00 PM. 1 Introduction 0. CSCI0330 Intro Computer Systems Doeppner Lab 02 - Tools Lab Due: Sunday, September 23, 2018 at 6:00 PM 1 Introduction 0 2 Assignment 0 3 gdb 1 3.1 Setting a Breakpoint 2 3.2 Setting a Watchpoint on Local

More information

To figure this out we need a more precise understanding of how ML works

To figure this out we need a more precise understanding of how ML works Announcements: What are the following numbers: 52/37/19/6 (2:30,3:35,11:15,7:30) PS2 due Thursday 9/22 11:59PM Quiz #1 back in section Monday Quiz #2 at start of class on Thursday 9/22 o HOP s, and lots

More information

COMP-202: Foundations of Programming. Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2015

COMP-202: Foundations of Programming. Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2015 COMP-202: Foundations of Programming Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2015 Assignment Due Date Assignment 1 is now due on Tuesday, Jan 20 th, 11:59pm. Quiz 1 is

More information

Using System.out.println()

Using System.out.println() Programming Assignments Read instructions carefully Many deduction on Program 3 for items in instructions Comment your code Coding conventions 20% of program grade going forward Class #23: Characters,

More information

CS/SE 153 Concepts of Compiler Design

CS/SE 153 Concepts of Compiler Design San José State University Department of Computer Science CS/SE 153 Concepts of Compiler Design Course and Contact Information Instructor: Ron Mak Office Location: ENG 250 Email: Website: Office Hours:

More information

CS 220: Introduction to Parallel Computing. Arrays. Lecture 4

CS 220: Introduction to Parallel Computing. Arrays. Lecture 4 CS 220: Introduction to Parallel Computing Arrays Lecture 4 Note: Windows I updated the VM image on the website It now includes: Sublime text Gitkraken (a nice git GUI) And the git command line tools 1/30/18

More information

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet.

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet. Mr G s Java Jive #2: Yo! Our First Program With this handout you ll write your first program, which we ll call Yo. Programs, Classes, and Objects, Oh My! People regularly refer to Java as a language that

More information

Practice Midterm 1 Answer Key

Practice Midterm 1 Answer Key CS 120 Software Design I Fall 2018 Practice Midterm 1 Answer Key University of Wisconsin - La Crosse Due Date: October 5 NAME: Do not turn the page until instructed to do so. This booklet contains 10 pages

More information

Homework 2: Imperative Due: 5:00 PM, Feb 15, 2019

Homework 2: Imperative Due: 5:00 PM, Feb 15, 2019 CS18 Integrated Introduction to Computer Science Fisler Homework 2: Imperative Due: 5:00 PM, Feb 15, 2019 Contents 1 Overview of Generic/Parameterized Types 2 2 Double the Fun with Doubly-Linked Lists

More information

Lecture 14. No in-class files today. Homework 7 (due on Wednesday) and Project 3 (due in 10 days) posted. Questions?

Lecture 14. No in-class files today. Homework 7 (due on Wednesday) and Project 3 (due in 10 days) posted. Questions? Lecture 14 No in-class files today. Homework 7 (due on Wednesday) and Project 3 (due in 10 days) posted. Questions? Friday, February 11 CS 215 Fundamentals of Programming II - Lecture 14 1 Outline Static

More information

CS/SE 153 Concepts of Compiler Design

CS/SE 153 Concepts of Compiler Design San José State University Department of Computer Science CS/SE 153 Concepts of Compiler Design Section 1 Fall 2018 Course and Contact Information Instructor: Ron Mak Office Location: ENG 250 Email: ron.mak@sjsu.edu

More information

: Distributed Systems Principles and Paradigms Assignment 1 Multithreaded Dictionary Server

: Distributed Systems Principles and Paradigms Assignment 1 Multithreaded Dictionary Server 433 652: Distributed Systems Principles and Paradigms Assignment 1 Multithreaded Dictionary Server Problem Description Using a client server architecture, design and implement a multi threaded server that

More information

Programming with Arrays Intro to Pointers CS 16: Solving Problems with Computers I Lecture #11

Programming with Arrays Intro to Pointers CS 16: Solving Problems with Computers I Lecture #11 Programming with Arrays Intro to Pointers CS 16: Solving Problems with Computers I Lecture #11 Ziad Matni Dept. of Computer Science, UCSB Thursday, 5/17 in this classroom Starts at 2:00 PM **SHARP** Please

More information

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit.

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit. Com S 227 Spring 2018 Miniassignment 1 40 points Due Date: Thursday, March 8, 11:59 pm (midnight) Late deadline (25% penalty): Friday, March 9, 11:59 pm General information This assignment is to be done

More information

Due Friday, March 20 at 11:59 p.m. Write and submit one Java program, Sequence.java, as described on the next page.

Due Friday, March 20 at 11:59 p.m. Write and submit one Java program, Sequence.java, as described on the next page. CS170 Section 5 HW #3 Due Friday, March 20 at 11:59 p.m. Write and submit one Java program, Sequence.java, as described on the next page. The assignment should be submitted on the Math/CS system (from

More information

CMPE 152 Compiler Design

CMPE 152 Compiler Design San José State University Department of Computer Engineering CMPE 152 Compiler Design Course and contact information Instructor: Ron Mak Office Location: ENG 250 Email: Website: Office Hours: Section 4

More information

COSC 2P95. Introduction. Week 1. Brock University. Brock University (Week 1) Introduction 1 / 18

COSC 2P95. Introduction. Week 1. Brock University. Brock University (Week 1) Introduction 1 / 18 COSC 2P95 Introduction Week 1 Brock University Brock University (Week 1) Introduction 1 / 18 Lectures and Labs Lectures are Thursdays, from 3pm 5pm (AS/STH 217) There are two lab sections Lab 1 is Mondays,

More information

Chapter 6 Introduction to Defining Classes

Chapter 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 information

Week 2. CS 400 Programming III. Read: Module 2 readings before lecture

Week 2. CS 400 Programming III. Read: Module 2 readings before lecture Week 2 Waitlisted Students: please come to front of class and sign by your name on waitlist. TopHat Join Code for my lecture: Announcements and Course Policies: https://pages.cs.wisc.edu/~deppeler/cs400/

More information

Austin Community College Google Apps Calendars Step-by-Step Guide

Austin Community College Google Apps Calendars Step-by-Step Guide The topics that will be covered in this workshop: Access (p.2) Calendar Settings (p.2) o General Tab (p.2) o Calendar Tab (p.3) Change Calendar Color (p.3) Calendar Notifications (p.4) Sharing (p.4) o

More information

Lab 1 Introduction to UNIX and C

Lab 1 Introduction to UNIX and C Name: Lab 1 Introduction to UNIX and C This first lab is meant to be an introduction to computer environments we will be using this term. You must have a Pitt username to complete this lab. The doc is

More information

Review: C Strings. A string in C is just an array of characters. Lecture #4 C Strings, Arrays, & Malloc

Review: C Strings. A string in C is just an array of characters. Lecture #4 C Strings, Arrays, & Malloc CS61C L4 C Pointers (1) inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #4 C Strings, Arrays, & Malloc Albert Chae Instructor 2008-06-26 Review: C Strings A string in C is just an array

More information

Unit 10: Data Structures CS 101, Fall 2018

Unit 10: Data Structures CS 101, Fall 2018 Unit 10: Data Structures CS 101, Fall 2018 Learning Objectives After completing this unit, you should be able to: Define and give everyday examples of arrays, stacks, queues, and trees. Explain what a

More information

Lesson 1A - First Java Program HELLO WORLD With DEBUGGING examples. By John B. Owen All rights reserved 2011, revised 2015

Lesson 1A - First Java Program HELLO WORLD With DEBUGGING examples. By John B. Owen All rights reserved 2011, revised 2015 Lesson 1A - First Java Program HELLO WORLD With DEBUGGING examples By John B. Owen All rights reserved 2011, revised 2015 Table of Contents Objectives Hello World Lesson Sequence Compile Errors Lexical

More information

Errors and Exceptions

Errors and Exceptions Exceptions Errors and Exceptions An error is a bug in your program dividing by zero going outside the bounds of an array trying to use a null reference An exception isn t necessarily your fault trying

More information

Announcements. 1. Forms to return today after class:

Announcements. 1. Forms to return today after class: Announcements Handouts (3) to pick up 1. Forms to return today after class: Pretest (take during class later) Laptop information form (fill out during class later) Academic honesty form (must sign) 2.

More information

Performance Measurement

Performance Measurement ECPE 170 Jeff Shafer University of the Pacific Performance Measurement 2 Lab Schedule Activities Today / Thursday Background discussion Lab 5 Performance Measurement Next Week Lab 6 Performance Optimization

More information

CS 170 Java Programming 1. Week 10: Loops and Arrays

CS 170 Java Programming 1. Week 10: Loops and Arrays CS 170 Java Programming 1 Week 10: Loops and Arrays What s the Plan? Topic 1: A Little Review Use a counted loop to create graphical objects Write programs that use events and animation Topic 2: Advanced

More information

CS162 Week 1. Kyle Dewey. Friday, January 10, 14

CS162 Week 1. Kyle Dewey. Friday, January 10, 14 CS162 Week 1 Kyle Dewey Overview Basic Introduction CS Accounts Scala survival guide Office Hour Choose an hour from within: Tuesday/Thursday 11 AM - 1 PM Friday 11 AM - 4 PM Also available by appointment

More information

CS61C : Machine Structures

CS61C : Machine Structures inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture 4 C Pointers 2004-09-08 Lecturer PSOE Dan Garcia www.cs.berkeley.edu/~ddgarcia Cal flies over Air Force We re ranked 13 th in the US and

More information

Day 8. COMP1006/1406 Summer M. Jason Hinek Carleton University

Day 8. COMP1006/1406 Summer M. Jason Hinek Carleton University Day 8 COMP1006/1406 Summer 2016 M. Jason Hinek Carleton University today s agenda assignments Assignment 4 is out and due on Tuesday Bugs and Exception handling 2 Bugs... often use the word bug when there

More information

Abstract Data Types (ADTs) Example ADTs. Using an Abstract Data Type. Class #08: Linear Data Structures

Abstract Data Types (ADTs) Example ADTs. Using an Abstract Data Type. Class #08: Linear Data Structures Abstract Data Types (ADTs) Class #08: Linear Data Structures Software Design III (CS 340): M. Allen, 08 Feb. 16 An ADT defines a kind of computational entity: A set of objects, with possible values A set

More information

Floating-point lab deadline moved until Wednesday Today: characters, strings, scanf Characters, strings, scanf questions clicker questions

Floating-point lab deadline moved until Wednesday Today: characters, strings, scanf Characters, strings, scanf questions clicker questions Announcements Thursday Extras: CS Commons on Thursdays @ 4:00 pm but none next week No office hours next week Monday or Tuesday Reflections: when to use if/switch statements for/while statements Floating-point

More information

CS/ENGRD 2110 SPRING 2018

CS/ENGRD 2110 SPRING 2018 CS/ENGRD 2110 SPRING 2018 Lecture 7: Interfaces and http://courses.cs.cornell.edu/cs2110 1 2 St Valentine s Day! It's Valentines Day, and so fine! Good wishes to you I consign.* But since you're my students,

More information

Result: original lp in main is. Goal was.

Result: original lp in main is. Goal was. CSE 12, Week Two, Lecture Two Thursday s Discussion Section: Getting started on hw3 Goal: Call a method that assigns a variable (a long) to zero; that variable exists elsewhere: void func ( ) { ; main

More information

EE 422C HW 6 Multithreaded Programming

EE 422C HW 6 Multithreaded Programming EE 422C HW 6 Multithreaded Programming 100 Points Due: Monday 4/16/18 at 11:59pm Problem A certain theater plays one show each night. The theater has multiple box office outlets to sell tickets, and the

More information

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit.

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit. Com S 227 Fall 2018 Miniassignment 1 40 points Due Date: Friday, October 12, 11:59 pm (midnight) Late deadline (25% penalty): Monday, October 15, 11:59 pm General information This assignment is to be done

More information

Lab 7 Unit testing and debugging

Lab 7 Unit testing and debugging CMSC160 Intro to Algorithmic Design Blaheta Lab 7 Unit testing and debugging 13 March 2018 Below are the instructions for the drill. Pull out your hand traces, and in a few minutes we ll go over what you

More information

17 February Given an algorithm, compute its running time in terms of O, Ω, and Θ (if any). Usually the big-oh running time is enough.

17 February Given an algorithm, compute its running time in terms of O, Ω, and Θ (if any). Usually the big-oh running time is enough. Midterm Review CSE 2011 Winter 2011 17 February 2011 1 Algorithm Analysis Given an algorithm, compute its running time in terms of O, Ω, and Θ (if any). Usually the big-oh running time is enough. Given

More information

HW1 due Monday by 9:30am Assignment online, submission details to come

HW1 due Monday by 9:30am Assignment online, submission details to come inst.eecs.berkeley.edu/~cs61c CS61CL : Machine Structures Lecture #2 - C Pointers and Arrays Administrivia Buggy Start Lab schedule, lab machines, HW0 due tomorrow in lab 2009-06-24 HW1 due Monday by 9:30am

More information

CS 315 Software Design Homework 3 Preconditions, Postconditions, Invariants Due: Sept. 29, 11:30 PM

CS 315 Software Design Homework 3 Preconditions, Postconditions, Invariants Due: Sept. 29, 11:30 PM CS 315 Software Design Homework 3 Preconditions, Postconditions, Invariants Due: Sept. 29, 11:30 PM Objectives Defining a wellformed method to check class invariants Using assert statements to check preconditions,

More information

Lecture 14: Exceptions 10:00 AM, Feb 26, 2018

Lecture 14: Exceptions 10:00 AM, Feb 26, 2018 CS18 Integrated Introduction to Computer Science Fisler, Nelson Lecture 14: Exceptions 10:00 AM, Feb 26, 2018 Contents 1 Exceptions and How They Work 1 1.1 Update to the Banking Example.............................

More information

CMPSCI 187 / Spring 2015 Sorting Kata

CMPSCI 187 / Spring 2015 Sorting Kata Due on Thursday, April 30, 8:30 a.m Marc Liberatore and John Ridgway Morrill I N375 Section 01 @ 10:00 Section 02 @ 08:30 1 Contents Overview 3 Learning Goals.................................................

More information

QUIZ How do we implement run-time constants and. compile-time constants inside classes?

QUIZ How do we implement run-time constants and. compile-time constants inside classes? QUIZ How do we implement run-time constants and compile-time constants inside classes? Compile-time constants in classes The static keyword inside a class means there s only one instance, regardless of

More information

CS354 gdb Tutorial Written by Chris Feilbach

CS354 gdb Tutorial Written by Chris Feilbach CS354 gdb Tutorial Written by Chris Feilbach Purpose This tutorial aims to show you the basics of using gdb to debug C programs. gdb is the GNU debugger, and is provided on systems that

More information

CS61C Machine Structures. Lecture 4 C Pointers and Arrays. 1/25/2006 John Wawrzynek. www-inst.eecs.berkeley.edu/~cs61c/

CS61C Machine Structures. Lecture 4 C Pointers and Arrays. 1/25/2006 John Wawrzynek. www-inst.eecs.berkeley.edu/~cs61c/ CS61C Machine Structures Lecture 4 C Pointers and Arrays 1/25/2006 John Wawrzynek (www.cs.berkeley.edu/~johnw) www-inst.eecs.berkeley.edu/~cs61c/ CS 61C L04 C Pointers (1) Common C Error There is a difference

More information

Overloading Functions & Command Line Use in C++ CS 16: Solving Problems with Computers I Lecture #6

Overloading Functions & Command Line Use in C++ CS 16: Solving Problems with Computers I Lecture #6 Overloading Functions & Command Line Use in C++ CS 16: Solving Problems with Computers I Lecture #6 Ziad Matni Dept. of Computer Science, UCSB A reminder about Labs Announcements Please make sure you READ

More information

Remotely Test Any Networked Equipment

Remotely Test Any Networked Equipment 1 Remotely Test Any Networked Equipment Universal Test Head Platform includes: Multiple Test Heads Scheduler Resource Balancing Database: Equipment Links Equipment History Test History Test Library Windows

More information

Lecture 7: Implementing Lists, Version 2

Lecture 7: Implementing Lists, Version 2 CS18 Integrated Introduction to Computer Science Fisler, Nelson Lecture 7: Implementing Lists, Version 2 Contents 1 The Impact of addfirst on Lists 1 2 Mutating List Contents 2 2.1 The Basic List Classes...................................

More information

CMPE 152 Compiler Design

CMPE 152 Compiler Design San José State University Department of Computer Engineering CMPE 152 Compiler Design Section 1 (Class) Sections 2 and 3 (s) Fall 2018 Course and Contact Information Instructor: Ron Mak Office Location:

More information

Lab: Supplying Inputs to Programs

Lab: Supplying Inputs to Programs Steven Zeil May 25, 2013 Contents 1 Running the Program 2 2 Supplying Standard Input 4 3 Command Line Parameters 4 1 In this lab, we will look at some of the different ways that basic I/O information can

More information

Exception Handling Generics. Amit Gupta

Exception Handling Generics. Amit Gupta Exception Handling Generics Amit Gupta Announcements Project 2 deadline 18 th Feb 9 pm. TA Consulting hours Mon Thurs B146 6 9 pm Exam 1 : Feb 15 4:30 5:20 pm Project 1 grading Exception Handling Computer

More information

Introduction to C. CS 2060 Week 1. Prof. Jonathan Ventura. Outline Introduction Introduction to C Homework 1 C Coding Style Wrap-up

Introduction to C. CS 2060 Week 1. Prof. Jonathan Ventura. Outline Introduction Introduction to C Homework 1 C Coding Style Wrap-up Outline Introduction Homework 1 C Coding Style Wrap-up CS 2060 Week 1 Outline Introduction Homework 1 C Coding Style Wrap-up 1 Introduction Why C? Syllabus and Course Structure 2 First C example: Hello,

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 11 February 5, 2018 Review: Abstract types Finite Maps Homework 3 due tomorrow at 11:59:59pm Announcements (Homework 4 is due Tuesday, 2/20, and won

More information

Due: 9 February 2017 at 1159pm (2359, Pacific Standard Time)

Due: 9 February 2017 at 1159pm (2359, Pacific Standard Time) CSE 11 Winter 2017 Program Assignment #2 (100 points) START EARLY! Due: 9 February 2017 at 1159pm (2359, Pacific Standard Time) PROGRAM #2: DoubleArray11 READ THE ENTIRE ASSIGNMENT BEFORE STARTING In lecture,

More information

CS 1110 SPRING 2016: GETTING STARTED (Jan 27-28) First Name: Last Name: NetID:

CS 1110 SPRING 2016: GETTING STARTED (Jan 27-28)   First Name: Last Name: NetID: CS 1110 SPRING 2016: GETTING STARTED (Jan 27-28) http://www.cs.cornell.edu/courses/cs1110/2016sp/labs/lab01/lab01.pdf First Name: Last Name: NetID: Goals. Learning a computer language is a lot like learning

More information

ECE 15B COMPUTER ORGANIZATION

ECE 15B COMPUTER ORGANIZATION ECE 15B COMPUTER ORGANIZATION Lecture 13 Strings, Lists & Stacks Announcements HW #3 Due next Friday, May 15 at 5:00 PM in HFH Project #2 Due May 29 at 5:00 PM Project #3 Assigned next Thursday, May 19

More information

CS 103 Lab The Files are *In* the Computer

CS 103 Lab The Files are *In* the Computer CS 103 Lab The Files are *In* the Computer 1 Introduction In this lab you will modify a word scramble game so that instead of using a hardcoded word list, it selects a word from a file. You will learn

More information

CS 215 Software Design Homework 3 Due: February 28, 11:30 PM

CS 215 Software Design Homework 3 Due: February 28, 11:30 PM CS 215 Software Design Homework 3 Due: February 28, 11:30 PM Objectives Specifying and checking class invariants Writing an abstract class Writing an immutable class Background Polynomials are a common

More information

CSC 101 Spring 2010 Lab #8 Report Gradesheet

CSC 101 Spring 2010 Lab #8 Report Gradesheet CSC 101 Spring 2010 Lab #8 Report Gradesheet Name WFU Username Lab Section: A B C D Partner s Name (if you had one): Topic Points Notes Pre-lab questions 20 total - 5 at 4 points each Lab report questions

More information

Number Review. Lecture #3 More C intro, C Strings, Arrays, & Malloc Variables. Clarification about counting down

Number Review. Lecture #3 More C intro, C Strings, Arrays, & Malloc Variables. Clarification about counting down CS61C L3 C Pointers (1) inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #3 More C intro, C Strings, Arrays, & Malloc Albert Chae Instructor 2008-06-25 Number Review Sign and magnitude

More information

CS61B Lecture #5: Arrays and Objects

CS61B Lecture #5: Arrays and Objects CS61B Lecture #5: Arrays and Objects For faster response, please send urgent problems (like the lab files don t compile ) as mail to cs61b, rather than using class messages. Homeworks are generally due

More information

CS 151. Recursion (Review!) Wednesday, September 19, 12

CS 151. Recursion (Review!) Wednesday, September 19, 12 CS 151 Recursion (Review!) 1 Announcements no class on Friday, and no office hours either (Alexa out of town) unfortunately, Alexa will also just be incommunicado, even via email, from Wednesday night

More information

CMSC 201 Spring 2018 Lab 01 Hello World

CMSC 201 Spring 2018 Lab 01 Hello World CMSC 201 Spring 2018 Lab 01 Hello World Assignment: Lab 01 Hello World Due Date: Sunday, February 4th by 8:59:59 PM Value: 10 points At UMBC, the GL system is designed to grant students the privileges

More information

CSC209. Software Tools and Systems Programming. https://mcs.utm.utoronto.ca/~209

CSC209. Software Tools and Systems Programming. https://mcs.utm.utoronto.ca/~209 CSC209 Software Tools and Systems Programming https://mcs.utm.utoronto.ca/~209 What is this Course About? Software Tools Using them Building them Systems Programming Quirks of C The file system System

More information

Outline. Review of Last Week II. Review of Last Week. Computer Memory. Review Variables and Memory. February 7, Data Types

Outline. Review of Last Week II. Review of Last Week. Computer Memory. Review Variables and Memory. February 7, Data Types Data Types Declarations and Initializations Larry Caretto Computer Science 16 Computing in Engineering and Science February 7, 25 Outline Review last week Meaning of data types Integer data types have

More information

CS Introduction to Programming Fall 2016

CS Introduction to Programming Fall 2016 CS 1113-300 Introduction to Programming Fall 2016 Exam 3 Review - Part 2 (Python) Friday, December 2 nd, 2016 Ahmed Ibrahim 1 / 26 Course Evaluation Please take a few minutes to submit your course evaluation

More information

* Due 11:59pm on Sunday 10/4 for Monday lab and Tuesday 10/6 Wednesday Lab

* Due 11:59pm on Sunday 10/4 for Monday lab and Tuesday 10/6 Wednesday Lab ===Lab Info=== *100 points * Due 11:59pm on Sunday 10/4 for Monday lab and Tuesday 10/6 Wednesday Lab ==Assignment== In this assignment you will work on designing a class for a binary search tree. You

More information

CMSC201 Computer Science I for Majors

CMSC201 Computer Science I for Majors CMSC201 Computer Science I for Majors Lecture 07 While Loops (cont) Last Class We Covered Using while loops Syntax of a while loop Interactive loops Infinite loops and other problems Practice with while

More information

CS61B Lecture #7. Announcements:

CS61B Lecture #7. Announcements: Announcements: CS61B Lecture #7 New discussion section: Tuesday 2 3PM in 310 Soda. New lab section: Thursday 2 4PM in 273 Soda. Programming Contest coming up: 5 October (new date). Watch for details. Last

More information

Review! * follows a pointer to its value! & gets the address of a variable! Pearce, Summer 2010 UCB! ! int x = 1000; Pearce, Summer 2010 UCB!

Review! * follows a pointer to its value! & gets the address of a variable! Pearce, Summer 2010 UCB! ! int x = 1000; Pearce, Summer 2010 UCB! CS61C L03 Introduction to C (pt 2) (1)! inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture 3 Introduction to C (pt 2) 2010-06-23!!!Instructor Paul Pearce! The typical! development cycle!

More information

More Examples Using Functions and Command-Line Arguments in C++ CS 16: Solving Problems with Computers I Lecture #6

More Examples Using Functions and Command-Line Arguments in C++ CS 16: Solving Problems with Computers I Lecture #6 More Examples Using Functions and Command-Line Arguments in C++ CS 16: Solving Problems with Computers I Lecture #6 Ziad Matni Dept. of Computer Science, UCSB Administrative CHANGED T.A. OFFICE/OPEN LAB

More information

CP Lab 5: Functions, pointers, some arrays

CP Lab 5: Functions, pointers, some arrays Computer Programming (CP) Lab 5, 2017/18 1 CP Lab 5: Functions, pointers, some arrays Instructions The purpose of this Lab is to help you get experience in understanding parameter-passing functions in

More information