Recitation #3 Comp 401-002 Semion Piskarev.

Slides:



Advertisements
Similar presentations
Classes, Exceptions, Collections, and Scrollable Controls
Advertisements

Chapter 1 Object-Oriented Concepts. A class consists of variables called fields together with functions called methods that act on those fields.
Web Application Development Slides Credit Umair Javed LUMS.
CS0007: Introduction to Computer Programming Introduction to Classes and Objects.
Objected Oriented Perl An introduction – because I don’t have the time or patience for an in- depth OOP lecture series…
Written by: Dr. JJ Shepherd
Software Engineering and Design Principles Chapter 1.
1 CS 106, Winter 2009 Class 10, Section 4 Slides by: Dr. Cynthia A. Brown, Instructor section 4: Dr. Herbert G. Mayer,
Encapsulation, Inheritance & Interfaces CSE 115 Spring 2006 February 27, March 1 & 3, 2006.
Eclipse – making OOP Easy
You gotta be cool. Introduction to Classes, Objects and Strings Introduction Defining a Class with a Member Function Defining a Member Function with a.
Classes and Objects. Topics The Class Definition Declaring Instance Member Variables Writing Instance Member Methods Creating Objects Sending Messages.
Programming Pillars Introduction to Object- Oriented Programming.
Working With Objects Tonga Institute of Higher Education.
Agenda Object Oriented Programming Reading: Chapter 14.
CIS 338: Classes and Modules Dr. Ralph D. Westfall May, 2011.
Chapter 4 -2 part Writing Classes 5 TH EDITION Lewis & Loftus java Software Solutions Foundations of Program Design © 2007 Pearson Addison-Wesley. All.
10-Nov-15 Java Object Oriented Programming What is it?
Topic 1 Object Oriented Programming. 1-2 Objectives To review the concepts and terminology of object-oriented programming To discuss some features of.
CS 376b Introduction to Computer Vision 01 / 23 / 2008 Instructor: Michael Eckmann.
1 CS161 Introduction to Computer Science Topic #9.
CourseOutline Example & JavaBeans Lec Start with Example Displaying Course Outlines User will select either course “web design & development” or.
1 Structure of a C Program (continued) Presentation original from Dr. Turner’s class USF - COP C for Engineers Summer 2008.
OOP with Objective-C Categories, Protocols and Declared Properties.
Python Let’s get started!.
Chapter More on Classes Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg.
Written by: Dr. JJ Shepherd
ITERATION. Iteration Computers are often used to automate repetitive tasks. Repeating identical or similar tasks without making errors is something that.
1 Introduction to Object Oriented Programming Chapter 10.
College Board Topics – A.P. Computer Science A Program Design - Read and understand a problem's description, purpose, and goals; Apply data abstraction.
5.1 Basics of defining and using classes A review of class and object definitions A class is a template or blueprint for an object A class defines.
OOP Basics Classes & Methods (c) IDMS/SQL News
Mr H Kandjimi 2016/01/03Mr Kandjimi1 Week 3 –Modularity in C++
Class Definitions and Writing Methods Chapter 3 3/31/16 & 4/4/16.
Class Definitions and Writing Methods Chapter 3 10/12/15 & 10/13/15 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education.
Class Definitions: The Fundamentals Chapter 6 3/30/15 & 4/2/15 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education.
Introduction to Classes and Objects CS-2303, C-Term C++ Program Structure Typical C++ Programs consist of:– main –A function main –One or more classes.
Classes CS 162 (Summer 2009). Parts of a Class Instance Fields Methods.
Andrew(amwallis) Classes!
EECS 183.
Object-Oriented Concepts
Classes C++ representation of an object
Classes and Objects.
Python Let’s get started!.
Scope and State Handling in JSPs
Topic: Functions – Part 2
Functions CIS 40 – Introduction to Programming in Python
Prof. Neary Adapted from slides by Dr. Katherine Gibson
Recitation 6 Inheritance.
Object Oriented Programming (OOP) LAB # 8
Recitation 4 Comp
Interfaces and Constructors
Lesson 5: Building an App: Clicker Game
Beans and object editor
Composite Objects with Object Editor With slides from Andrew Ghobrial
Tonga Institute of Higher Education
Object-Oriented Programming
Recitation 5 In this recitation you will have an example on displaying multiple objects on ObjectEditor. The code can be found in the recitation page.
CMSC202 Computer Science II for Majors Lecture 07 – Classes and Objects (Continued) Dr. Katherine Gibson Based on slides by Chris Marron at UMBC.
Java IDE Dwight Deugo Nesa Matic Portions of the notes for this lecture include excerpts from.
Web Design & Development Lecture 4
Review of Previous Lesson
Classes C++ representation of an object
CMPT 120 Lecture 4 – Unit 1 – Chatbots
Intro to Programming (in JavaScript)
CSG2H3 Object Oriented Programming
Parameters and Arguments
Lecture 2 – Abstract Data Type (ADT)
Introduction to Computer Science and Object-Oriented Programming
Object-Oriented Design AND CLASS PROPERTIES
Presentation transcript:

Recitation #3 Comp 401-002 Semion Piskarev

Review: why classes? Tedious and unreliable

Class as a Type

Class for Modularization

Constructors Constructor gets called

Why Getters and Setters?

Using Getters and Setters Or… In this case, you don’t even need to have an “area” variable stored! A “JavaBean” class is one that only lets things be accessed with getters and setters. A property is something that can be accessed through a getter or setter.

Today’s topic: Why interfaces? Can’t keep up- what if someone makes something else I can call?

Interfaces Will work for anything that implements “Callable”!

Informal definitions Modularity: the ability to add, remove, and exchange parts without having to change EVERYTHING Encapsulation: keeping the workings of a class hidden or contained inside it as much as possible Polymorphism: Letting code correctly work with data of many forms (types) Modularity and encapsulation allow pieces of code to have some independence, so different people can work on different parts. Modularity and polymorphism allow code to be reused in many contexts.

Today’s Activity Go to the course website -> click Recitations Scroll down and click on “Activity Slides” under “Interfaces and Annotations”

What you’ll do Create an interface that specifies some getters and setters Implement the interface in a class End up with a Bean class Get to see the Object Editor, a class created by Dr. Dewan that you will soon start using in your assignments

Creating an interface Notice the semicolon. This is a “declaration”, not a “definition” of a function.

To do: Implementing the interface: Code for scanning a string: 1. Create an interface named “UppercaseFilter” that requires the following methods: getInputString() – takes no arguments, returns a String setInputString() – takes a String as an argument, returns nothing getUppercaseLetters()- takes no arguments, returns a String 2. Create a class named AnUpperCaseFilter that: Implements the interface When you call getUppercaseLetters(), returns a string of the uppercase letters. Methods print out statements when called (ex: “setInputString is called”) Has the annotations required (placed above the class name) 3. Create a class named “Driver” with this code: 4. Run the Driver, and submit a screenshot on Sakai Implementing the interface: This will add the method headers for you Code for scanning a string: