BIT 115: Introduction To Programming LECTURE 3. Instructor: Craig Duckett

Size: px
Start display at page:

Download "BIT 115: Introduction To Programming LECTURE 3. Instructor: Craig Duckett"

Transcription

1 BIT 115: Introduction To Programming LECTURE 3 Instructor: Craig Duckett cduckett@cascadia.edu

2 Lecture 3 Announcements By now everyone should be up and running with Java, jgrasp, and the Becker Robots on their home or personal computers. Any Problems? Has everyone had a chance to work with the Java programs and the Becker Robots? Reading Assignment for Today Appendix F.1 Extending a Class Chapter 2.1, 2.2 Extending Robot Class Chapter 2.4 Coding Style BIT 115: Introduction To Programming 2

3 TIRED OF CIRCLING THE PARKING LOTS? In case you are not aware, Cascadia has a new option for students and staff who drive to campus. Campus Commuter Services has begun operating the Truly Express shuttle service between campus and an overflow parking lot 1.2 miles away at the Seattle Times building. This should help to alleviate the parking lot traffic jams. The Truly Express makes four stops: 1) Across from the Activities and Recreation Center 2) The parking lot at the Beardslee Professional Building 3) At Beardslee Crossing near the metro bus stop 4) At the Seattle Times parking th Ave NE The Truly Express runs from 7:00 am until 10:50 pm every Monday through Thursday. The schedule is posted on the website. You can also download the live shuttle app to track the Truly Express. The campus parking spots are clearly labeled and a pay station has been installed. If you are parking on a regular basis, you will save money by purchasing a parking permit. You can find information about the shuttle, parking, bus routes, ORCA U-Pass, carpooling, and other commuter services online. Shuttle schedule: Live shuttle tracker app: Parking information:

4 In-Class Exercises (ICEs) You do not have to submit ICEs, since I grade these in-class. If you finish all your ICEs early and I sign you off on them, you are done and you can leave the class early. If you are working on the ICEs until the end of class, but did not finish them, you will still get full credit for working on them, but it is HIGHLY RECOMMENDED that you finish the ICEs on your own outside of class since they have been designed to help you with the concepts that will be used in the Assignments. If you want, you can show me that you have completed the ICEs during the next ICE-time in the next Lecture. Starting with Lecture 4, I will start posting Solutions to most (but not all) of the ICEs. 4

5 H O M E W O R K Assignment 1 is Due LECTURE 5 Zipped & Uploaded to StudentTracker by MIDNIGHT SECTION 1: Monday, January 22 nd It s posted on the website under Assignments menu It will be due by midnight If unsure how to upload to StudentTracker, then bring your work to class, in electronic form, and we will go over how to hand in the homework: Student Tracker How to Use Student Tracker If you re stuck, seek help Talk to the Instructor or a classmate me FYI: You should have enough information after today s lecture to successfully complete Assignment 1 5

6 Assignment Dates (By Due Date) Assignment 1 (LECTURE 5) Section 1: Monday, January 22 nd The Fickle Finger of Fate Assignment 2 (LECTURE 8) Section 1: Wednesday, January 31 st Assignment 1 Revision (LECTURE 10) Section 1: Wednesday, February 7 th Assignment 2 Revision (LECTURE 12) Section 1: Wednesday, February 14 th Assignment 3 (LECTURE 13) Section 1: Wednesday, February 21 st Assignment 3 Revision (LECTURE 16) Section 1: Monday, March 5 th Assignment 4 (LECTURE 18) NO REVISION AVAILABLE! Section 1: Monday, March 12 th 6

7 And Now. The First Quiz! You each get a Quiz hand-out: Put your name on it When you think your drawing is complete, raise your hand 5 minute limit Going forward, always leave your completed quiz beside your throughout the Lecture (and the Quarter) because your Instructor will use these to learn your names 7

8 Lecture 3 Buckle up! This could really Extending a Class : Creating a new type of Robot Style and Java Coding Conventions 8

9 Appendix F.1, Chapter 2.1, 2.2 Extending a Class Extension (B extends A) Extending the Robot Class Superclass and Subclass Constructor Adding a Method (Service) turnaround(); turnright(); The This Keyword (Implicit Parameter) Putting It All Together BIT 115: Introduction To Programming 9

10 Constructors and Extending a Class

11 Object Class Left Right In Java and other programming languages code is rendered from right to left. City Bothell = new City(); City Object City Class No Arguments City Bothell = new City(8, 10); City Object City Class With Arguments Robot Robbie = new Robot(Bothell, 3, 0, Direction.EAST, 0); Robot Object Robot Class With Arguments 11

12 Constructors Here, when we create a new instance (an object) of the Robot class, a hidden default constructor works in the background to make sure that Kelsey inherits all the attributes and methods available to Robots, including its placement on a particular Street and Avenue and Direction in a particular City, and that it can use all of the actions (methods) available to the Robot class (including move(), pickthing(), turnleft(), putthing(), frontisclear(), etc.) BIT 115: Introduction To Programming 12

13 Constructors Constructors have one purpose in life: to create an instance of a class. This can also be called creating an object, as in: The purpose of a method, by contrast is much more general. The purpose of a method is to execute Java code, to act, to allow the object to do something. 13

14 BIT 115: Introduction To Programming 14

15 Robot Class Constructor The Robot class constructor has already been built for use and is part of the becker.jar file. We can look at this constructor by examining the Becker Library at There we see there are two types of constructors that can be used, one that has four elements and one that has five elements. Let's look at both these constructors to see what the difference is, and what the individual elements represent. 15

16 Robot Class Constructor The four part constructor represents the creation of a Robot object without a backpack to hold Things. The five part constructor represents the creation of a Robot object with a backpack to hold Things. Both these constructors also represent that type of data that will be stored in memory, and sets up memory locations to hold those values (either four or five) that are passed inside the Robot class's parentheses. These parentheses in programming are called parameters, and the values being passed are called arguments. 16

17 Now what if these is an action that you might want Kelsey to do that isn t found in the Robot class? For instance, instead of invoking the the turnleft() method three times, you could just call up a turnright()? The problem is, the Robot class does not have a turnright() command (method). The Robot class has been finalized. You cannot add to it. The good news is, you can create a new method like turnright() that will do what you want the robot to do! But in order to make this happen, you need to extend the Robot class In other words, you re going to make a new class from the Robot class so you can add new methods to it like turnright() BIT 115: Introduction To Programming 17

18 Extending a Class 18

19 Extending a Class: Where Class B extends Class A In Plain Old English: Where Class B inherits all the attributes and actions of Class A and then adds it s own functionality by creating new methods When we re not interested in extending a class because we re happy with the methods that come with that class just the way they are, then we declare our class the normal default way: public class Example extends Object Object is the top class of all class hierarchies. When a new instance of anything is made in Java, then it inherits all the attributes and actions of the Object class. You can t get a new object without Object. Object Class Hierarchy However, if we want to add new functionality (methods) to the Class A class then we need to extend the Class A class (which is itself an extension of Object) and create a new class from it called Class B. Class B has all the actions and attributes of Class A, plus any new ones we give it. 19

20 Extending the Robot Class Now the Robot class has a specific set of actions and attributes. If you create a named Object from the Robot class (like Karel), then Karel can use the move() method and the turnleft() method, but Karel cannot use a turnright() method because that method is not part of the Robot class. If you want to use a turnright() method than you will have to extend the Robot class and make a new class from it so you can create your own methods. In this example, we're going to extend the Robot class and create a new class from it called MrRoboto. public class MrRoboto extends Robot An Object made from the MrRoboto class can do everything an Object made from the Robot class can do, plus any additional methods we create for it, like turnright(). 20

21 Instantiation (Instance) vs. Extension (Extends) Instantiation creates a new object from a class, but extension extends a new class from a class through inheritance, allowing for an improved class that might offer additional attributes and services (methods) not available in the original class Let's look at this in the abstract first, and then we'll look at some code to see how it works. 21

22 Think of it as adding an extension to a house. You still get to use all of the original house, but you also get to use the new section you added to the house 22

23 Extending the Robot Class public class MrRoboto extends Robot MrRoboto extends inherits Robot MrRoboto inherits all of the Robot attributes and services and then can have additional attributes and services of its own (i.e., those not shared by Robot). BIT 115: Introduction To Programming 23

24 Superclass and Subclass Robot Superclass move() turnleft() pickthing() putthing() MrRoboto Subclass move3() turnaround() turnright() An Object created from the MrRoboto subclass inherits all the actions and attributes of the Robot class, and can use any new actions and attributes (methods) created for the MrRoboto class. 24

25 Constructor import becker.robots.*; public class MrRoboto extends Robot { public MrRoboto(City thecity, int street, int avenue, Direction adirection) { super(thecity, street, avenue, adirection); } } //New methods (actions, services) go here BIT 115: Introduction To Programming 25

26 Constructor import becker.robots.*; public class MrRoboto extends Robot { // This declares the parameters used by Robot inside of MrRoboto public MrRoboto(City thecity, int street, int avenue, Direction adirection) // This passes on information received by the parameters used by Robot inside of MrRoboto { super(thecity, street, avenue, adirection); //Instead of Robot here, Java uses the keyword super } } //New methods (actions, services) go here Constructors fulfill a special roll. They are responsible for ensuring an object is set up properly when it is created, and that it can be immediately used once it is created. This construction process is known as initialization. Two other details about constructors: they must have the same name as the class and they do not have a return type, not even a void. NOTE: We will talk briefly about return types in just a few minutes, and go over them in greater detail in an upcoming lecture. BIT 115: Introduction To Programming 26

27 Constructor public class MrRoboto extends Robot { public MrRoboto(City thecity, int street, int avenue, Direction adirection) { super(thecity, street, avenue, adirection); } } MrRoboto Robot BIT 115: Introduction To Programming 27

28 Constructor public class MrRoboto extends Robot { public MrRoboto(City thecity, int street, int avenue, Direction adirection) { super(thecity, street, avenue, adirection); } } MrRoboto Robot super BIT 115: Introduction To Programming 28

29 Constructor public class MrRoboto extends Robot { public MrRoboto(City thecity, int street, int avenue, Direction adirection) { super(thecity, street, avenue, adirection); } } MrRoboto imagine a conduit super BIT 115: Introduction To Programming 29

30 Constructor public class MrRoboto extends Robot { public MrRoboto(City thecity, int street, int avenue, Direction adirection) { super(thecity, street, avenue, adirection); } } bothell, 3, 2, Direction.SOUTH MrRoboto super Since MrRoboto is inheriting the Robot parameters, the Robot still needs those parameters in order for MrRoboto to inherit them. This is why it appears as if there are two sets of parameters: one set to pass through MrRoboto, a second set for Robot to receive them, where Robot sends them back to MrRoboto by extension. BIT 115: Introduction To Programming 30

31 Creating New Methods 31

32 Adding New Methods (Actions) public void turnaround() { this.turnleft(); this.turnleft(); } public void move3() { this.move(); this.move(); this.move(); } public void turnright() { this.turnaround(); this.turnleft(); } 32

33 The This Keyword 33

34 The this keyword The new Java feature in the new services we created is the use of the this keyword. The keyword this is useful when you need to refer to an instance of the class from its method, but without having to refer to it by a specific name. Why? Because when you create the new method, you don t know the name of the particular robot that is going to use it, so this is a kind of placeholder name. The this keyword helps us to avoid name conflicts, and also creates a shortcut to having to invent a unique name for each field in the different methods. public void turnaround() { this.turnleft(); this.turnleft(); } 34

35 Putting It All Together Two Ways of Doing the Same Thing, however: THE CLASS THAT CONTAINS MAIN HAS TO BE THE SAME NAME AS THE FILE Version 1: One Class MrRoboto.java Version 2: Two Classes MrRobotoMain.java 35

36 Putting It All Together MrRoboto2.java MrRoboto.java All on One File On Two Separate Files MrRobotoTest2.java 36

37 Chapter 2.4 Coding Conventions (Style) These coding conventions are not only good for Java, but for other languages as well, including C, C++, C#, JavaScript, Perl, Python, etc., to name a few. 37

38 Please Note! CityFrame! IMPORTANT! CityFrame An older version of becker.jar file contained a class called CityFrame which when used looked something like this: CityFrame City = CityFrame(someCity); Please ignore any reference to this. It will, however, rear its ugly head in the ICEs and Assignments on purpose as an example of old 'legacy' code that should either be "commented out" with // or deleted altogether since it will not allow the program to run correctly! // CityFrame City = CityFrame(someCity); 38

39 Lecture 3 ICE: Creating a New Type of Robot 39

Asking For Help. BIT 115: Introduction To Programming 1

Asking For Help. BIT 115: Introduction To Programming 1 Asking For Help Start homeworks As Soon As Possible You may post homework questions to Canvas: Please do not cut and paste entire lines of code, but rather ask conceptual questions. You may also ask me

More information

Lecture 6. Instructor: Craig Duckett

Lecture 6. Instructor: Craig Duckett Lecture 6 Instructor: Craig Duckett Assignment 1, 2, and A1 Revision Assignment 1 I have finished correcting and have already returned the Assignment 1 submissions. If you did not submit an Assignment

More information

Lecture 12. Instructor: Craig Duckett

Lecture 12. Instructor: Craig Duckett Lecture 12 Instructor: Craig Duckett Assignment 2 Revision DUE TONIGHT! Uploaded to StudentTracker by midnight YOUR LAST CHANCE TO EARN POINTS! Assignment 3 Maze DUE Lecture 13 Uploaded to StudentTracker

More information

Instructor: Craig Duckett

Instructor: Craig Duckett Instructor: Craig Duckett cduckett@cascadia.edu Announcements Assignment 1 Due Lecture 5 by MIDNIGHT I will double dog dare try to have Assignment 1 graded and back to you by Wednesday, January 24 th hopefully

More information

Variables and Classes. In which we over-ride the super class, work with multiple classes, and move towards non-robot based programming

Variables and Classes. In which we over-ride the super class, work with multiple classes, and move towards non-robot based programming Variables and Classes In which we over-ride the super class, work with multiple classes, and move towards non-robot based programming Classes Class extends Class attributes:

More information

Lecture 7. Instructor: Craig Duckett OUTPUT

Lecture 7. Instructor: Craig Duckett OUTPUT Lecture 7 Instructor: Craig Duckett OUTPUT Lecture 7 Announcements ASSIGNMENT 2 is due LECTURE 8 NEXT LECTURE uploaded to StudentTracker by midnight Assignment 2!!! Assignment Dates (By Due Date) Assignment

More information

Lecture 8. A series on variable types This episode starring Parameter Variables

Lecture 8. A series on variable types This episode starring Parameter Variables Lecture 8 A series on variable types This episode starring Parameter Variables Declaring an Integer Variable Variable Types Variable Type How it is defined Scope (how long it lasts) Uses Local Variable

More information

Lecture 11. Instructor: Craig Duckett. Instance Variables

Lecture 11. Instructor: Craig Duckett. Instance Variables Lecture 11 Instructor: Craig Duckett Instance Variables Assignment Dates (By Due Date) Assignment 1 (LECTURE 5) GRADED! Section 1: Monday, January 22 nd Assignment 2 (LECTURE 8) GRADED! Section 1: Wednesday,

More information

Lecture 10. Instructor: Craig Duckett

Lecture 10. Instructor: Craig Duckett Lecture 10 Instructor: Craig Duckett Announcements Assignment 1 Revision DUE TONIGHT in StudentTracker by midnight If you have not yet submitted an Assignment 1, this is your last chance to do so to earn

More information

Lecture 2 Announcements

Lecture 2 Announcements Lecture 2 Announcements Home Computers and/or Laptops/Notebooks By now you should have installed Java SE 8 and jgrasp on your computers, set up the becker.jar file, and started working with some of the

More information

Combo Lecture Lecture 14/15. Instructor: Craig Duckett

Combo Lecture Lecture 14/15. Instructor: Craig Duckett Combo Lecture Lecture 14/15 Instructor: Craig Duckett Assignment Dates (By Due Date) Assignment 1 (LECTURE 5) GRADED! Section 1: Monday, January 22 nd Assignment 2 (LECTURE 8) GRADED! Section 1: Wednesday,

More information

Extending Classes with Services

Extending Classes with Services Extending Classes with Services 2 2 Author s Do-List: add a concept map Extending an existing class to do something new is the fundamental activity of object-oriented programming. Sometimes an existing

More information

Lecture 8 " INPUT " Instructor: Craig Duckett

Lecture 8  INPUT  Instructor: Craig Duckett Lecture 8 " INPUT " Instructor: Craig Duckett Assignments Assignment 2 Due TONIGHT Lecture 8 Assignment 1 Revision due Lecture 10 Assignment 2 Revision Due Lecture 12 We'll Have a closer look at Assignment

More information

Lecture 17. Instructor: Craig Duckett. Passing & Returning Arrays

Lecture 17. Instructor: Craig Duckett. Passing & Returning Arrays Lecture 17 Instructor: Craig Duckett Passing & Returning Arrays Assignment Dates (By Due Date) Assignment 1 (LECTURE 5) GRADED! Section 1: Monday, January 22 nd Assignment 2 (LECTURE 8) GRADED! Section

More information

Programming Karel the Robot

Programming Karel the Robot Programming Karel the Robot Announcements Five Handouts Today: Honor Code Downloading Eclipse Running Karel Programs in Eclipse Programming Assignment #1 Submitting Programming Assignments Please only

More information

ASSIGNMENT 3 Classes, Objects and the Robot World

ASSIGNMENT 3 Classes, Objects and the Robot World ASSIGNMENT 3 Classes, Objects and the Robot World COMP-202B, Winter 2009, All Sections Due: Tuesday, March 3, 2009 (23:55) You MUST do this assignment individually and, unless otherwise specified, you

More information

CS112 Lecture: Defining Instantiable Classes

CS112 Lecture: Defining Instantiable Classes CS112 Lecture: Defining Instantiable Classes Last revised 2/3/05 Objectives: 1. To describe the process of defining an instantiable class 2. To discuss public and private visibility modifiers. Materials:

More information

Lecture 13. Instructor: Craig Duckett. Boolean Expressions, Logical Operators, and Return Values

Lecture 13. Instructor: Craig Duckett. Boolean Expressions, Logical Operators, and Return Values Lecture 13 Instructor: Craig Duckett Boolean Expressions, Logical Operators, and Return Values Assignment 3: The Maze DUE TONIGHT! Uploaded to StudentTracker by midnight If you are submitting as part of

More information

CS112 Lecture: Defining Classes. 1. To describe the process of defining an instantiable class

CS112 Lecture: Defining Classes. 1. To describe the process of defining an instantiable class CS112 Lecture: Defining Classes Last revised 2/3/06 Objectives: 1. To describe the process of defining an instantiable class Materials: 1. BlueJ SavingsAccount example project 2. Handout of code for SavingsAccount

More information

CSE : Python Programming

CSE : Python Programming CSE 399-004: Python Programming Lecture 2: Data, Classes, and Modules January 22, 2007 http://www.seas.upenn.edu/~cse39904/ Administrative things Teaching assistant Brian Summa (bsumma @ seas.upenn.edu)

More information

EECS 1001 and EECS 1030M, lab 01 conflict

EECS 1001 and EECS 1030M, lab 01 conflict EECS 1001 and EECS 1030M, lab 01 conflict Those students who are taking EECS 1001 and who are enrolled in lab 01 of EECS 1030M should switch to lab 02. If you need my help with switching lab sections,

More information

Tips from the experts: How to waste a lot of time on this assignment

Tips from the experts: How to waste a lot of time on this assignment Com S 227 Spring 2018 Assignment 1 80 points Due Date: Friday, February 2, 11:59 pm (midnight) Late deadline (25% penalty): Monday, February 5, 11:59 pm General information This assignment is to be done

More information

Robots. Byron Weber Becker. chapter 6

Robots. Byron Weber Becker. chapter 6 Using Variables Robots Learning to Program with Java Byron Weber Becker chapter 6 Announcements (Oct 3) Reminder: Reading for today y( (Oct 3 rd ) Ch 6.1-6.4 Reading for Wednesday (Oct 3 rd ) The rest

More information

CS112 Lecture: Extending Classes and Defining Methods

CS112 Lecture: Extending Classes and Defining Methods Objectives: CS112 Lecture: Extending Classes and Defining Methods Last revised 1/9/04 1. To introduce the idea of extending existing classes to add new methods 2. To introduce overriding of inherited methods

More information

Instructor: Craig Duckett. Lecture 02: Thursday, March 29 th, 2018 SQL Basics and SELECT, FROM, WHERE

Instructor: Craig Duckett. Lecture 02: Thursday, March 29 th, 2018 SQL Basics and SELECT, FROM, WHERE Instructor: Craig Duckett Lecture 02: Thursday, March 29 th, 2018 SQL Basics and SELECT, FROM, WHERE 1 Assignment 1 is due LECTURE 5, Tuesday, April 10 th, 2018 in StudentTracker by MIDNIGHT MID-TERM EXAM

More information

Media Computation. Lecture 16.1, December 8, 2008 Steve Harrison

Media Computation. Lecture 16.1, December 8, 2008 Steve Harrison Media Computation Lecture 16.1, December 8, 2008 Steve Harrison Today -- Details of Creating Classes From requirements to classes Creating a class that will simulate a number game Practice going from requirements

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

Developing and Reusing Methods

Developing and Reusing Methods Developing and Reusing Methods 3 In Chapter 2, we wrote new services such as turnright and turnaround. These services were very simple, consisting of only a few steps to accomplish the task. In this chapter,

More information

CPS122 Lecture: Defining a Class

CPS122 Lecture: Defining a Class Objectives: CPS122 Lecture: Defining a Class last revised January 14, 2016 1. To introduce structure of a Java class 2. To introduce the different kinds of Java variables (instance, class, parameter, local)

More information

ASSIGNMENT 4 Records and Objects

ASSIGNMENT 4 Records and Objects ASSIGNMENT 4 Records and Objects COMP-202B, Winter 2010, All Sections Due: Wednesday, March 31, 2010 (23:55) You MUST do this assignment individually and, unless otherwise specified, you MUST follow all

More information

CS/ENGRD 2110 FALL Lecture 2: Objects and classes in Java

CS/ENGRD 2110 FALL Lecture 2: Objects and classes in Java 1 CS/ENGRD 2110 FALL 2017 Lecture 2: Objects and classes in Java http://courses.cs.cornell.edu/cs2110 CMS VideoNote.com, PPT slides, DrJava 2 CMS. Visit course webpage, click Links, then CMS for 2110.

More information

CSE 113 A. Announcements - Lab

CSE 113 A. Announcements - Lab CSE 113 A February 21-25, 2011 Announcements - Lab Lab 1, 2, 3, 4; Practice Assignment 1, 2, 3, 4 grades are available in Web-CAT look under Results -> Past Results and if looking for Lab 1, make sure

More information

Tips from the experts: How to waste a lot of time on this assignment

Tips from the experts: How to waste a lot of time on this assignment Com S 227 Spring 2018 Assignment 1 100 points Due Date: Friday, September 14, 11:59 pm (midnight) Late deadline (25% penalty): Monday, September 17, 11:59 pm General information This assignment is to be

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

ASSIGNMENT 4 Classes and Objects

ASSIGNMENT 4 Classes and Objects ASSIGNMENT 4 Classes and Objects COMP-202A, Fall 2010, All Sections Due: Friday, November 19, 2010 (23:55) You MUST do this assignment individually and, unless otherwise specified, you MUST follow all

More information

Introduction to Computers and Engineering Problem Solving Spring 2012 Problem Set 5: MBTA routes Due: 12 noon, Friday, March 23

Introduction to Computers and Engineering Problem Solving Spring 2012 Problem Set 5: MBTA routes Due: 12 noon, Friday, March 23 Introduction to Computers and Engineering Problem Solving Spring 2012 Problem Set 5: MBTA routes Due: 12 noon, Friday, March 23 Problem statement a. Overview The Massachusetts Bay Transportation Authority

More information

INF 111 / CSE 121. Homework 3: Code Reading

INF 111 / CSE 121. Homework 3: Code Reading Homework 3: Code Reading Laboratory Date: Thursday, July 2, 2009 Take Home Due: Monday, July 2, 2009 Name : Student Number : Laboratory Time : Instructions for the Laboratory Objectives Open a project

More information

Slide 1 CS 170 Java Programming 1 Testing Karel

Slide 1 CS 170 Java Programming 1 Testing Karel CS 170 Java Programming 1 Testing Karel Introducing Unit Tests to Karel's World Slide 1 CS 170 Java Programming 1 Testing Karel Hi Everybody. This is the CS 170, Java Programming 1 lecture, Testing Karel.

More information

Lab 2: Object-Oriented Design 12:00 PM, Jan 31, 2018

Lab 2: Object-Oriented Design 12:00 PM, Jan 31, 2018 CS18 Integrated Introduction to Computer Science Fisler, Nelson Contents Lab 2: Object-Oriented Design 12:00 PM, Jan 31, 2018 1 Terminology 1 2 Class Hierarchy Diagrams 2 2.1 An Example: Animals...................................

More information

C++ Important Questions with Answers

C++ Important Questions with Answers 1. Name the operators that cannot be overloaded. sizeof,.,.*,.->, ::,? 2. What is inheritance? Inheritance is property such that a parent (or super) class passes the characteristics of itself to children

More information

Today. Homework 1 / Test 1 Making decisions in Java If statements If/Else ( Either-or ) statements Logical NOT operator

Today. Homework 1 / Test 1 Making decisions in Java If statements If/Else ( Either-or ) statements Logical NOT operator Today Homework 1 / Test 1 Making decisions in Java If statements If/Else ( Either-or ) statements Logical NOT operator BIT 115: Introduction To Programming 1 Something to Remember: In parameter order,

More information

Lecture 3. COMP1006/1406 (the Java course) Summer M. Jason Hinek Carleton University

Lecture 3. COMP1006/1406 (the Java course) Summer M. Jason Hinek Carleton University Lecture 3 COMP1006/1406 (the Java course) Summer 2014 M. Jason Hinek Carleton University today s agenda assignments 1 (graded) & 2 3 (available now) & 4 (tomorrow) a quick look back primitive data types

More information

Title: Counting While Loops

Title: Counting While Loops Title: Counting While Loops Erik Boling, Panitz, Bit115, Winter Quarter 2011 Assignment Definition And General Feedback By Michael Panitz at Cascadia Community College (http://www.cascadia.edu) Table of

More information

Practice Midterm Examination #1

Practice Midterm Examination #1 Eric Roberts Handout #35 CS106A May 2, 2012 Practice Midterm Examination #1 Review session: Sunday, May 6, 7:00 9:00 P.M., Hewlett 200 Midterm exams: Tuesday, May 8, 9:00 11:00 A.M., CEMEX Auditorium Tuesday,

More information

Polymorphism. Object Orientated Programming in Java. Benjamin Kenwright

Polymorphism. Object Orientated Programming in Java. Benjamin Kenwright Polymorphism Object Orientated Programming in Java Benjamin Kenwright Quizzes/Labs Every single person should have done Quiz 00 Introduction Quiz 01 - Java Basics Every single person should have at least

More information

MET CS 674 C1/EL Spring 2017: DATABASE SECURITY SYLLABUS

MET CS 674 C1/EL Spring 2017: DATABASE SECURITY SYLLABUS MET CS 674 C1/EL Spring 2017: DATABASE SECURITY Boston University Metropolitan College Boston Campus and elive Schedule Thursday 18:00-21:00 US Eastern Time Location Room B36 College of Arts and Sciences

More information

Chapter 1 Getting Started

Chapter 1 Getting Started Chapter 1 Getting Started The C# class Just like all object oriented programming languages, C# supports the concept of a class. A class is a little like a data structure in that it aggregates different

More information

COMSC-051 Java Programming Part 1. Part-Time Instructor: Joenil Mistal

COMSC-051 Java Programming Part 1. Part-Time Instructor: Joenil Mistal COMSC-051 Java Programming Part 1 Part-Time Instructor: Joenil Mistal Chapter 4 4 Moving Toward Object- Oriented Programming This chapter provides a provides an overview of basic concepts of the object-oriented

More information

CS/ENGRD 2110 SPRING Lecture 3: Fields, getters and setters, constructors, testing

CS/ENGRD 2110 SPRING Lecture 3: Fields, getters and setters, constructors, testing 1 CS/ENGRD 2110 SPRING 2019 Lecture 3: Fields, getters and setters, constructors, testing http://courses.cs.cornell.edu/cs2110 CS2110 Announcements 2 Take course S/U? OK with us. Check with your advisor/major.

More information

Assignment #1: /Survey and Karel the Robot Karel problems due: 1:30pm on Friday, October 7th

Assignment #1:  /Survey and Karel the Robot Karel problems due: 1:30pm on Friday, October 7th Mehran Sahami Handout #7 CS 06A September 8, 06 Assignment #: Email/Survey and Karel the Robot Karel problems due: :0pm on Friday, October 7th Email and online survey due: :9pm on Sunday, October 9th Part

More information

Mehran Sahami Handout #7 CS 106A September 24, 2014

Mehran Sahami Handout #7 CS 106A September 24, 2014 Mehran Sahami Handout #7 CS 06A September, 0 Assignment #: Email/Survey and Karel the Robot Karel problems due: :pm on Friday, October rd Email and online survey due: :9pm on Sunday, October th Part I

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

Java Object Oriented Design. CSC207 Fall 2014

Java Object Oriented Design. CSC207 Fall 2014 Java Object Oriented Design CSC207 Fall 2014 Design Problem Design an application where the user can draw different shapes Lines Circles Rectangles Just high level design, don t write any detailed code

More information

Survey #2. Programming Assignment 3. Final Exam. University of British Columbia CPSC 111, Intro to Computation Alan J. Hu.

Survey #2. Programming Assignment 3. Final Exam. University of British Columbia CPSC 111, Intro to Computation Alan J. Hu. University of British Columbia CPSC 111, Intro to Computation Alan J. Hu Accessing the Superclass Object Hierarchies is-a, has-a Readings This Week: Ch 9.4-9.5 and into Ch 10.1-10.8 (Ch 11.4-11.5 and into

More information

CSC-140 Assignment 6

CSC-140 Assignment 6 CSC-140 Assignment 6 1 Introduction In this assignment we will start out defining our own classes. For now, we will design a class that represents a date, e.g., Tuesday, March 15, 2011, or in short hand

More information

Instructor: Craig Duckett. Lecture 07: Tuesday, April 17 th, 2018 Conflicts and Isolation, MySQL Workbench

Instructor: Craig Duckett. Lecture 07: Tuesday, April 17 th, 2018 Conflicts and Isolation, MySQL Workbench Instructor: Craig Duckett Lecture 07: Tuesday, April 17 th, 2018 Conflicts and Isolation, MySQL Workbench 1 MID-TERM EXAM is LECTURE 10, Tuesday, May 1st Assignment 2 is due LECTURE 12, Tuesday, May 8

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

Rules and syntax for inheritance. The boring stuff

Rules and syntax for inheritance. The boring stuff Rules and syntax for inheritance The boring stuff The compiler adds a call to super() Unless you explicitly call the constructor of the superclass, using super(), the compiler will add such a call for

More information

Robots. Byron Weber Becker. chapter 6

Robots. Byron Weber Becker. chapter 6 Using Variables Robots Learning to Program with Java Byron Weber Becker chapter 6 Announcements (Oct 5) Chapter 6 You don t have to spend much time on graphics in Ch6 Just grasp the concept Reminder: Reading

More information

Programming Exercise 14: Inheritance and Polymorphism

Programming Exercise 14: Inheritance and Polymorphism Programming Exercise 14: Inheritance and Polymorphism Purpose: Gain experience in extending a base class and overriding some of its methods. Background readings from textbook: Liang, Sections 11.1-11.5.

More information

Lesson 10A OOP Fundamentals. By John B. Owen All rights reserved 2011, revised 2014

Lesson 10A OOP Fundamentals. By John B. Owen All rights reserved 2011, revised 2014 Lesson 10A OOP Fundamentals By John B. Owen All rights reserved 2011, revised 2014 Table of Contents Objectives Definition Pointers vs containers Object vs primitives Constructors Methods Object class

More information

CS/ENGRD 2110 SPRING Lecture 2: Objects and classes in Java

CS/ENGRD 2110 SPRING Lecture 2: Objects and classes in Java 1 CS/ENGRD 2110 SPRING 2017 Lecture 2: Objects and classes in Java http://courses.cs.cornell.edu/cs2110 CMS VideoNote.com, PPT slides, DrJava, Book 2 CMS available. Visit course webpage, click Links, then

More information

Software Paradigms (Lesson 3) Object-Oriented Paradigm (2)

Software Paradigms (Lesson 3) Object-Oriented Paradigm (2) Software Paradigms (Lesson 3) Object-Oriented Paradigm (2) Table of Contents 1 Reusing Classes... 2 1.1 Composition... 2 1.2 Inheritance... 4 1.2.1 Extending Classes... 5 1.2.2 Method Overriding... 7 1.2.3

More information

Assignment #1: and Karel the Robot Karel problems due: 3:15pm on Friday, October 4th due: 11:59pm on Sunday, October 6th

Assignment #1:  and Karel the Robot Karel problems due: 3:15pm on Friday, October 4th  due: 11:59pm on Sunday, October 6th Mehran Sahami Handout #7 CS 06A September, 0 Assignment #: Email and Karel the Robot Karel problems due: :pm on Friday, October th Email due: :9pm on Sunday, October 6th Part I Email Based on a handout

More information

Physics 2660: Fundamentals of Scientific Computing. Lecture 3 Instructor: Prof. Chris Neu

Physics 2660: Fundamentals of Scientific Computing. Lecture 3 Instructor: Prof. Chris Neu Physics 2660: Fundamentals of Scientific Computing Lecture 3 Instructor: Prof. Chris Neu (chris.neu@virginia.edu) Announcements Weekly readings will be assigned and available through the class wiki home

More information

Lecture 13: more class, C++ memory management

Lecture 13: more class, C++ memory management CIS 330: / / / / (_) / / / / _/_/ / / / / / \/ / /_/ / `/ \/ / / / _/_// / / / / /_ / /_/ / / / / /> < / /_/ / / / / /_/ / / / /_/ / / / / / \ /_/ /_/_/_/ _ \,_/_/ /_/\,_/ \ /_/ \ //_/ /_/ Lecture 13:

More information

Instructor: Anna Miller

Instructor: Anna Miller Media Graphics ADV 3203 Fall 2016 Advertising Media Graphics - 81584 - ADV 3203 Mondays and Wednesdays 12:15 PM - 1:30 PM room 1011 And Advertising Media Graphics - 82354 - ADV 3203 Mondays and Wednesdays

More information

Introduction to HTML

Introduction to HTML TOR Part 2 Introduction to HTML TOR Part 2: Introduction 1 of 2 1/23/2007 12:19 PM GSLIS Technology Orientation Requirement (TOR) TOR Part 2: Assessment 10: Introduction to HTML Possible Points: 9 Points

More information

Class Note #02. [Overall Information] [During the Lecture]

Class Note #02. [Overall Information] [During the Lecture] Class Note #02 Date: 01/11/2006 [Overall Information] In this class, after a few additional announcements, we study the worst-case running time of Insertion Sort. The asymptotic notation (also called,

More information

Lesson Share TEACHER'S NOTES LESSON SHARE. ing by Olya Sergeeva. Overview. Preparation. Procedure

Lesson Share TEACHER'S NOTES LESSON SHARE.  ing by Olya Sergeeva. Overview. Preparation. Procedure Lesson Share TEACHER'S NOTES Age: Adults Level: Intermediate + Time: 1 hour 40 minutes Objective: to practise writing work-related emails Key skills: writing Materials: one copy of the worksheet per student;

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

CS193P - Lecture 3. iphone Application Development. Custom Classes Object Lifecycle Autorelease Properties

CS193P - Lecture 3. iphone Application Development. Custom Classes Object Lifecycle Autorelease Properties CS193P - Lecture 3 iphone Application Development Custom Classes Object Lifecycle Autorelease Properties 1 Announcements Assignments 1A and 1B due Wednesday 1/13 at 11:59 PM Enrolled Stanford students

More information

This tool is actually pretty unique and has evolved over the last 7 years. I have been working with Adobe Connect for quite awhile now and one of the

This tool is actually pretty unique and has evolved over the last 7 years. I have been working with Adobe Connect for quite awhile now and one of the 1 2 This tool is actually pretty unique and has evolved over the last 7 years. I have been working with Adobe Connect for quite awhile now and one of the things that I have noticed is that they do tend

More information

First IS-A Relationship: Inheritance

First IS-A Relationship: Inheritance First IS-A Relationship: Inheritance The relationships among Java classes form class hierarchy. We can define new classes by inheriting commonly used states and behaviors from predefined classes. A class

More information

Check out FilesAndExceptions from SVN. Exam 2 Review File I/O, Exceptions Vector Graphics Project

Check out FilesAndExceptions from SVN. Exam 2 Review File I/O, Exceptions Vector Graphics Project Check out FilesAndExceptions from SVN Exam 2 Review File I/O, Exceptions Vector Graphics Project Exam 2 review File I/O and Exceptions Vector Graphics project kickoff Exam is in class tomorrow Test on

More information

Lecture 5. Defining Functions

Lecture 5. Defining Functions Lecture 5 Defining Functions Announcements for this Lecture Last Call Quiz: About the Course Take it by tomorrow Also remember the survey Readings Sections 3.5 3.3 today Also 6.-6.4 See online readings

More information

Changing an Object s Properties

Changing an Object s Properties Go ahead and PULL Lecture Materials & Sign-in on PollEv Right Click Lecture > Team > Pull Poll Everywhere: pollev.com/comp110 Lecture 4 Changing an Object s Properties Fall 2016 Announcements Review Session

More information

Tips from the experts: How to waste a lot of time on this assignment

Tips from the experts: How to waste a lot of time on this assignment Com S 227 Spring 2017 Assignment 1 80 points Due Date: Thursday, February 2, 11:59 pm (midnight) Late deadline (25% penalty): Friday, February 3, 11:59 pm General information This assignment is to be done

More information

CSE115 / CSE503 Introduction to Computer Science I. Dr. Carl Alphonce 343 Davis Hall Office hours:

CSE115 / CSE503 Introduction to Computer Science I. Dr. Carl Alphonce 343 Davis Hall Office hours: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu Office hours: Thursday 12:00 PM 2:00 PM Friday 8:30 AM 10:30 AM OR request appointment via e-mail

More information

Lecture 10. Overriding & Casting About

Lecture 10. Overriding & Casting About Lecture 10 Overriding & Casting About Announcements for This Lecture Readings Sections 4.2, 4.3 Prelim, March 8 th 7:30-9:30 Material up to next Tuesday Sample prelims from past years on course web page

More information

EECE.2160: ECE Application Programming Spring 2017

EECE.2160: ECE Application Programming Spring 2017 Course Meetings Section 201: MWF 8-8:50, Ball 314 Section 202: MWF 12-12:50, Kitson 305 Course Website Main page: http://mjgeiger.github.io/eece2160/sp17/ Schedule: http://mjgeiger.github.io/eece2160/sp17/schedule.htm

More information

Creative Computing Course Syllabus 1 semester for High School (110 contact hours)

Creative Computing Course Syllabus 1 semester for High School (110 contact hours) CodeHS Creative Computing Course Syllabus 1 semester for High School (110 contact hours) Course Overview and Goals The Creative Computing course is a first year computer science course introducing the

More information

You must pass the final exam to pass the course.

You must pass the final exam to pass the course. Computer Science Technology Department Houston Community College System Department Website: http://csci.hccs.cc.tx.us CRN: 46876 978-1-4239-0146-4 1-4239-0146-0 Semester: Fall 2010 Campus and Room: Stafford

More information

CMPSCI 187 / Spring 2015 Implementing Sets Using Linked Lists

CMPSCI 187 / Spring 2015 Implementing Sets Using Linked Lists CMPSCI 187 / Spring 2015 Implementing Sets Using Linked Lists Due on Tuesday February 24, 2015, 8:30 a.m. Marc Liberatore and John Ridgway Morrill I N375 Section 01 @ 10:00 Section 02 @ 08:30 1 CMPSCI

More information

QUIZ. How could we disable the automatic creation of copyconstructors

QUIZ. How could we disable the automatic creation of copyconstructors QUIZ How could we disable the automatic creation of copyconstructors pre-c++11? What syntax feature did C++11 introduce to make the disabling clearer and more permanent? Give a code example. Ch. 14: Inheritance

More information

Lecture 4. Defining Functions

Lecture 4. Defining Functions Lecture 4 Defining Functions Academic Integrity Quiz Remember: quiz about the course AI policy Have posted grades for completed quizes Right now, missing ~130 enrolled students If did not receive at least

More information

Instructor: Craig Duckett. Lecture 04: Thursday, April 5, Relationships

Instructor: Craig Duckett. Lecture 04: Thursday, April 5, Relationships Instructor: Craig Duckett Lecture 04: Thursday, April 5, 2018 Relationships 1 Assignment 1 is due NEXT LECTURE 5, Tuesday, April 10 th in StudentTracker by MIDNIGHT MID-TERM EXAM is LECTURE 10, Tuesday,

More information

CMPSCI 187 / Spring 2015 Hanoi

CMPSCI 187 / Spring 2015 Hanoi Due on Thursday, March 12, 2015, 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

Laboratory 1: Eclipse and Karel the Robot

Laboratory 1: Eclipse and Karel the Robot Math 121: Introduction to Computing Handout #2 Laboratory 1: Eclipse and Karel the Robot Your first laboratory task is to use the Eclipse IDE framework ( integrated development environment, and the d also

More information

Arrays Classes & Methods, Inheritance

Arrays Classes & Methods, Inheritance Course Name: Advanced Java Lecture 4 Topics to be covered Arrays Classes & Methods, Inheritance INTRODUCTION TO ARRAYS The following variable declarations each allocate enough storage to hold one value

More information

Announcements. Course syllabus Tutorial/lab signup form (due 4pm today) Lecture 1 notes Homework 1 Initial assessment

Announcements. Course syllabus Tutorial/lab signup form (due 4pm today) Lecture 1 notes Homework 1 Initial assessment Announcements Handouts (5) to pick up Course syllabus Tutorial/lab signup form (due 4pm today) Lecture 1 notes Homework 1 Initial assessment Please do it now and hand it in as you leave lecture It s ungraded;

More information

COMP-202 Unit 0: Course Details

COMP-202 Unit 0: Course Details COMP-202 Unit 0: Course Details CONTENTS: Focus of the Course and Prerequisites Outline and Textbook Course Structure and Grading Scheme Computer Lab Info and Required Software Getting started thinking

More information

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

COMP200 INTERFACES. OOP using Java, from slides by Shayan Javed 1 1 COMP200 INTERFACES OOP using Java, from slides by Shayan Javed Interfaces 2 ANIMAL picture food sleep() roam() makenoise() eat() 3 ANIMAL picture food sleep() roam() makenoise() eat() 4 roam() FELINE

More information

CS 251 Intermediate Programming Inheritance

CS 251 Intermediate Programming Inheritance CS 251 Intermediate Programming Inheritance Brooke Chenoweth University of New Mexico Spring 2018 Inheritance We don t inherit the earth from our parents, We only borrow it from our children. What is inheritance?

More information

Inheritance and Interfaces

Inheritance and Interfaces Inheritance and Interfaces Object Orientated Programming in Java Benjamin Kenwright Outline Review What is Inheritance? Why we need Inheritance? Syntax, Formatting,.. What is an Interface? Today s Practical

More information

5.6.1 The Special Variable this

5.6.1 The Special Variable this ALTHOUGH THE BASIC IDEAS of object-oriented programming are reasonably simple and clear, they are subtle, and they take time to get used to And unfortunately, beyond the basic ideas there are a lot of

More information

CS/ENGRD 2110 SPRING Lecture 2: Objects and classes in Java

CS/ENGRD 2110 SPRING Lecture 2: Objects and classes in Java 1 CS/ENGRD 2110 SPRING 2014 Lecture 2: Objects and classes in Java http://courses.cs.cornell.edu/cs2110 Java OO (Object Orientation) 2 Python and Matlab have objects and classes. Strong-typing nature of

More information

This course supports the assessment for Scripting and Programming Applications. The course covers 4 competencies and represents 4 competency units.

This course supports the assessment for Scripting and Programming Applications. The course covers 4 competencies and represents 4 competency units. This course supports the assessment for Scripting and Programming Applications. The course covers 4 competencies and represents 4 competency units. Introduction Overview Advancements in technology are

More information

C++ Inheritance I. CSE 333 Spring Instructor: Justin Hsia

C++ Inheritance I. CSE 333 Spring Instructor: Justin Hsia C++ Inheritance I CSE 333 Spring 2018 Instructor: Justin Hsia Teaching Assistants: Danny Allen Dennis Shao Eddie Huang Kevin Bi Jack Xu Matthew Neldam Michael Poulain Renshu Gu Robby Marver Waylon Huang

More information

Math Olympiads Registration Information & FAQ

Math Olympiads Registration Information & FAQ Registration Information & FAQ Thank you for your interest in our popular Math Olympiads course. In order to ensure your registration is valid and processed correctly it is imperative that you read carefully

More information