Programming II (CS300)
|
|
- Lionel Palmer
- 5 years ago
- Views:
Transcription
1 1 Programming II (CS300) Chapter 03: Creating Classes MOUNA KACEM Spring 2018
2 Creating Classes 2 Constructors and Object Initialization Static versus non-static fields/methods Encapsulation Practice Example Introduction to Abstraction Keep in Mind
3 Constructors and Object Initialization 3 In Java, an object is an instance of any non-primitive type When a reference type is declared, no object is allocated. At that point, the reference is to null Objects must be explicitly constructed Objects are created with the operator new new calls a special type of subroutine called constructor When invocated, the constructor allocates memory for the object, initializes the object s instance variables, and returns a reference to the object
4 Constructors and Object Initialization 4 A constructor does not have any return type (not even void) The name of the constructor must be the same as the name of the class in which it is defined A constructor can t be declared static Every class has at least one constructor default constructor Does not take any argument allocate memory and initialize instance variables Overloaded constructor
5 Static versus non-static fields/methods 5 Static fields, variables, and constants have values that are shared across all instances (objects) of a particular class Static fields and methods belong to the Class rather than to an individual object No instance of the class is required in order to use a static field or a static method Non-static fields and non-static methods defined in a class can be used only when an object of that class has been created Heap (memory Allocation) Code Static Memory Stack (method call) console.log() Main() JVM
6 Creating Classes 6 Constructors and Object Initialization Static versus non-static fields/methods Encapsulation Practice Example (1) Introduction to Abstraction Practice Example (2) Keep in Mind
7 Encapsulation Concept 7 Encapsulation refers to information hiding The fact of packaging a number of features of an entity/object in a capsule to form a single unit In object-oriented programming, the single unit combining data and methods is called a Class
8 How to enforce Encapsulation Class 8 Class Private Fields (data) Public methods (behavior) private String field1; private int field2; To enforce encapsulation Hidden information Visible information The data is hidden : not accessed directly (private fields) The operations are visible: accessed directly (public methods) public void setfield1 (String s){ public String getfield1 (){ public void operationx( ){ Fields of the class are manipulated using public getter and setter methods (accessors and mutators)
9 Practice Example 9 Create a Student class with the following: A String variable named name to store the student s name An integer variable named uniqueid that contains the unique ID number for this student An integer class variable named nextuniqueid that contains the unique ID number for the next student A String variable named DoB to store the student s date of birth An integer class variable named numberofstudents that keeps track of the number of students that have been created so far A constructor Student(String name, String DoB) Several public get/set methods for all the class fields
10 Practice Example 10 public class Student { private String name; private int uniqueid; private String DoB; //Constructor public Student(String name, String DoB) { this.name = name; this.dob = DoB;
11 Practice Example 11 public class Student { private String name; private int uniqueid; private static int nextuniqueid = 1; private String DoB; private static int numberofstudents = 0; //Constructor public Student(String name, String DoB) { this.name = name; uniqueid = nextuniqueid; nextuniqueid++; this.dob = DoB; numberofstudents++; //Get and set methods for all properties public String getname() { return name; public void setname(string newname) { name = newname; public int getuniqueid() { return uniqueid; public int getnextuniqueid() { return nextuniqueid; public String getdob() { return DoB; public void setdob(string newdob) { DoB = newdob; public int getnumberofstudents() { return numberofstudents;
12 Practice Example 12 Execution Trace
13 Encapsulation: Advantages 13 Encapsulation provides a layer of security around the manipulated data protecting it from external interference and mis-use A class can have total control over what is stored in its fields The users of a class ignore how the class stores the data The fields of a class can be made ready-only or write-only by providing getter and setter methods as the only access points to these fields from the outside of the class Encapsulation promotes the code s Maintainability Flexibility extensibility
14 Introduction to Abstraction 14 Abstraction Essential element of object-oriented programming Abstraction specifies necessary and sufficient descriptions rather than the implementation details Hiding internal implementation details of an object from the user In a real-world problem, humans manage complexity through abstraction Abstraction allows people to focus on what an object is able to do rather than on its technical implementation Car iphone
15 Creating Classes 15 Constructors and Object Initialization Static versus non-static fields/methods Encapsulation Practice Example (1) Introduction to Abstraction Practice Example (2) Keep in Mind
16 Introduction to Abstraction 16 Abstraction Providing the essential features of an entity/object without including the implementation details hide unnecessary details of an object from the user In Object-Oriented Programming, a feature can be An attribute/field reflecting a property (data or state) An operation reflecting a method (or behavior or function)
17 Abstraction versus Encapsulation 17
18 Abstraction versus Encapsulation 18 Abstraction Separates interface and implementation Provides access to a specific part of the data (Users know only how to use the visible part of the data according to the abstraction without allowing access to the implementation details) The ability to encapsulate and isolate design from execution information Encapsulation Groups related concepts into one unit Encapsulation hides data and users have only access to them through the accessors and mutators methods Encapsulation is a concept embedded in abstraction
19 Keep in Mind 19 A constructor defines how an object is declared and initialized. A constructor is a method that has the same name as the class and no return type If you write a constructor with return type void, you have actually written a method with the same name as the class, but this is NOT a constructor A class may define multiple constructors A constructor is invoked using the keyword new Private members cannot be accessed outside of the class.
20 Keep in Mind 20 Encapsulation is the process of combining data and functions into a single unit called class To enforce encapsulation, define the class fields as private and define public getter and setter methods are to manipulate them Private members (fields or methods) cannot be accessed outside of the class Abstraction is a process where you show only relevant data and hide unnecessary details of an object from the user. The class consists of two parts: the specification (accessible) and the implementation (hidden)
Programming II (CS300)
1 Programming II (CS300) Chapter 03: Creating Classes MOUNA KACEM mouna@cs.wisc.edu Spring 2019 Creating Classes 2 Constructors and Object Initialization Static versus non-static fields/methods Encapsulation
More informationProgramming II (CS300)
1 Programming II (CS300) Chapter 02: Using Objects MOUNA KACEM mouna@cs.wisc.edu Fall 2018 Using Objects 2 Introduction to Object Oriented Programming Paradigm Objects and References Memory Management
More informationChapter 4 Defining Classes I
Chapter 4 Defining Classes I This chapter introduces the idea that students can create their own classes and therefore their own objects. Introduced is the idea of methods and instance variables as the
More informationCmSc 150 Fundamentals of Computing I. Lesson 28: Introduction to Classes and Objects in Java. 1. Classes and Objects
CmSc 150 Fundamentals of Computing I Lesson 28: Introduction to Classes and Objects in Java 1. Classes and Objects True object-oriented programming is based on defining classes that represent objects with
More informationCLASSES AND OBJECTS IN JAVA
Lesson 8 CLASSES AND OBJECTS IN JAVA (1) Which of the following defines attributes and methods? (a) Class (b) Object (c) Function (d) Variable (2) Which of the following keyword is used to declare Class
More informationProgramming II (CS300)
1 Programming II (CS300) Chapter 02: Using Objects MOUNA KACEM mouna@cs.wisc.edu Spring 2018 Using Objects 2 Introduction to Object Oriented Programming Paradigm Objects and References Memory Management
More informationChapter 4: Writing Classes
Chapter 4: Writing Classes Java Software Solutions Foundations of Program Design Sixth Edition by Lewis & Loftus Writing Classes We've been using predefined classes. Now we will learn to write our own
More informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationENCAPSULATION AND POLYMORPHISM
MODULE 3 ENCAPSULATION AND POLYMORPHISM Objectives > After completing this lesson, you should be able to do the following: Use encapsulation in Java class design Model business problems using Java classes
More informationLecture 07: Object Encapsulation & References AITI Nigeria Summer 2012 University of Lagos.
Accelerating Information Technology Innovation http://aiti.mit.edu Lecture 07: Object Encapsulation & References AITI Nigeria Summer 2012 University of Lagos. Data Field Encapsulation Sometimes we want
More informationCS111: PROGRAMMING LANGUAGE II. Lecture 1: Introduction to classes
CS111: PROGRAMMING LANGUAGE II Lecture 1: Introduction to classes Lecture Contents 2 What is a class? Encapsulation Class basics: Data Methods Objects Defining and using a class In Java 3 Java is an object-oriented
More informationDay 3. COMP 1006/1406A Summer M. Jason Hinek Carleton University
Day 3 COMP 1006/1406A Summer 2016 M. Jason Hinek Carleton University today s agenda assignments 1 was due before class 2 is posted (be sure to read early!) a quick look back testing test cases for arrays
More informationObjects and Classes. 1 Creating Classes and Objects. CSCI-UA 101 Objects and Classes
Based on Introduction to Java Programming, Y. Daniel Liang, Brief Version, 10/E 1 Creating Classes and Objects Classes give us a way of defining custom data types and associating data with operations on
More informationChapter 4. Defining Classes I
Chapter 4 Defining Classes I Introduction Classes are the most important language feature that make object-oriented programming (OOP) possible Programming in Java consists of defining a number of classes
More informationLecture 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 information5. Defining Classes and Methods
5. Defining Classes and Methods Harald Gall, Prof. Dr. Institut für Informatik Universität Zürich http://seal.ifi.uzh.ch/info1 Objectives! Describe and define concepts of class and object! Describe use
More informationENCAPSULATION. private, public, scope and visibility rules. packages and package level access.
ENCAPSULATION private, public, scope and visibility rules. packages and package level access. Q. Explain the term Encapsulation with an example? Ans: The wrapping up to data and methods into a single units
More informationCS1004: Intro to CS in Java, Spring 2005
CS1004: Intro to CS in Java, Spring 2005 Lecture #13: Java OO cont d. Janak J Parekh janak@cs.columbia.edu Administrivia Homework due next week Problem #2 revisited Constructors, revisited Remember: a
More informationWeek 5-1: ADT Design
Week 5-1: ADT Design Part1. ADT Design Define as class. Every obejects are allocated in heap space. Encapsulation : Data representation + Operation Information Hiding : Object's representation part hides,
More informationEECS168 Exam 3 Review
EECS168 Exam 3 Review Exam 3 Time: 2pm-2:50pm Monday Nov 5 Closed book, closed notes. Calculators or other electronic devices are not permitted or required. If you are unable to attend an exam for any
More informationCS 251 Intermediate Programming Methods and More
CS 251 Intermediate Programming Methods and More Brooke Chenoweth University of New Mexico Spring 2018 Methods An operation that can be performed on an object Has return type and parameters Method with
More informationGetter and Setter Methods
Example 1 namespace ConsoleApplication14 public class Student public int ID; public string Name; public int Passmark = 50; class Program static void Main(string[] args) Student c1 = new Student(); Console.WriteLine("please..enter
More informationProgramming II (CS300)
1 Programming II (CS300) Chapter 05: Inheritance and Interfaces MOUNA KACEM mouna@cs.wisc.edu Fall 2018 Inheritance and Interfaces 2 Introduction Inheritance and Class Hierarchy Polymorphism Abstract Classes
More informationCIS3023: Programming Fundamentals for CIS Majors II Summer 2010
CIS3023: Programming Fundamentals for CIS Majors II Summer 2010 Objects and Classes (contd.) Course Lecture Slides 19 May 2010 Ganesh Viswanathan Objects and Classes Credits: Adapted from CIS3023 lecture
More informationDistributed Systems Recitation 1. Tamim Jabban
15-440 Distributed Systems Recitation 1 Tamim Jabban Office Hours Office 1004 Tuesday: 9:30-11:59 AM Thursday: 10:30-11:59 AM Appointment: send an e-mail Open door policy Java: Object Oriented Programming
More informationECE 122. Engineering Problem Solving with Java
ECE 122 Engineering Problem Solving with Java Lecture 6 Problem Definition and Implementation Outline Problem: Create, read in and print out four sets of student grades Setting up the problem Breaking
More informationDefining Classes and Methods
Defining Classes and Methods Chapter 5 Modified by James O Reilly Class and Method Definitions OOP- Object Oriented Programming Big Ideas: Group data and related functions (methods) into Objects (Encapsulation)
More informationCSC1322 Object-Oriented Programming Concepts
CSC1322 Object-Oriented Programming Concepts Instructor: Yukong Zhang February 18, 2016 Fundamental Concepts: The following is a summary of the fundamental concepts of object-oriented programming in C++.
More informationClasses. Classes as Code Libraries. Classes as Data Structures
Classes Classes/Objects/Interfaces (Savitch, Various Chapters) TOPICS Classes Public versus Private Static Data Static Methods Interfaces Classes are the basis of object-oriented (OO) programming. They
More informationCS1150 Principles of Computer Science Methods
CS1150 Principles of Computer Science Methods Yanyan Zhuang Department of Computer Science http://www.cs.uccs.edu/~yzhuang CS1150 UC. Colorado Springs Opening Problem Find the sum of integers from 1 to
More informationAn Introduction to C++
An Introduction to C++ Introduction to C++ C++ classes C++ class details To create a complex type in C In the.h file Define structs to store data Declare function prototypes The.h file serves as the interface
More informationMethods and Data (Savitch, Chapter 5)
Methods and Data (Savitch, Chapter 5) TOPICS Invoking Methods Return Values Local Variables Method Parameters Public versus Private 2 public class Temperature { public static void main(string[] args) {
More informationCS 251 Intermediate Programming Methods and Classes
CS 251 Intermediate Programming Methods and Classes Brooke Chenoweth University of New Mexico Fall 2018 Methods An operation that can be performed on an object Has return type and parameters Method with
More informationHandout 7. Defining Classes part 1. Instance variables and instance methods.
Handout 7 CS180 Programming Fundamentals Spring 15 Page 1 of 8 Handout 7 Defining Classes part 1. Instance variables and instance methods. In Object Oriented programming, applications are comprised from
More informationObject-Oriented Programming Concepts
Object-Oriented Programming Concepts Real world objects include things like your car, TV etc. These objects share two characteristics: they all have state and they all have behavior. Software objects are
More informationProgramming II (CS300)
1 Programming II (CS300) Chapter 05: Inheritance and Interfaces MOUNA KACEM mouna@cs.wisc.edu Spring 2018 Inheritance and Interfaces 2 Introduction Inheritance and Class Hierarchy Polymorphism Abstract
More informationThis Week. Fields and Variables. W05 Example 1: Variables & Fields. More on Java classes. Constructors. Modifiers
This Week More on Java classes School of Computer Science University of St Andrews Graham Kirby Alan Dearle Constructors Modifiers cdn.videogum.com/img/thumbnails/photos/commenter.jpg http://www.rodgersleask.co.uk/images/sc2.jpg
More informationChapter 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 informationEncapsulation. Mason Vail Boise State University Computer Science
Encapsulation Mason Vail Boise State University Computer Science Pillars of Object-Oriented Programming Encapsulation Inheritance Polymorphism Abstraction (sometimes) Object Identity Data (variables) make
More informationAnatomy of a Class Encapsulation Anatomy of a Method
Writing Classes Writing Classes We've been using predefined classes. Now we will learn to write our own classes to define objects Chapter 4 focuses on: class definitions instance data encapsulation and
More informationProgramming II (CS300)
1 Programming II (CS300) Chapter 9 (Part II) Recursion MOUNA KACEM Recursion: General Overview 2 Recursion in Algorithms Recursion is the use of recursive algorithms to solve a problem A recursive algorithm
More informationNotes on Chapter Three
Notes on Chapter Three Methods 1. A Method is a named block of code that can be executed by using the method name. When the code in the method has completed it will return to the place it was called in
More informationClasses and Objects 3/28/2017. How can multiple methods within a Java class read and write the same variable?
Peer Instruction 8 Classes and Objects How can multiple methods within a Java class read and write the same variable? A. Allow one method to reference a local variable of the other B. Declare a variable
More informationCS 302 Week 9. Jim Williams
CS 302 Week 9 Jim Williams This Week P2 Milestone 3 Lab: Instantiating Classes Lecture: Wrapper Classes More Objects (Instances) and Classes Next Week: Spring Break Will this work? Double d = new Double(10);
More information5. Defining Classes and Methods
5. Defining Classes and Methods Harald Gall, Prof. Dr. Institut für Informatik Universität Zürich http://seal.ifi.uzh.ch/info1 Objectives Describe and define concepts of class, class object Describe use
More informationCOMP Information Hiding and Encapsulation. Yi Hong June 03, 2015
COMP 110-001 Information Hiding and Encapsulation Yi Hong June 03, 2015 Review of Pass-By-Value What is the output? public void swap(student s1, Student s2) Student s3 = s1; s1 = s2; s2 = s3; Student berkeley
More informationCS1150 Principles of Computer Science Methods
CS1150 Principles of Computer Science Methods Yanyan Zhuang Department of Computer Science http://www.cs.uccs.edu/~yzhuang CS1150 UC. Colorado Springs Opening Problem Find the sum of integers from 1 to
More informationClasses. Classes. Classes. Class Circle with methods. Class Circle with fields. Classes and Objects in Java. Introduce to classes and objects in Java.
Classes Introduce to classes and objects in Java. Classes and Objects in Java Understand how some of the OO concepts learnt so far are supported in Java. Understand important features in Java classes.
More informationAP Computer Science Chapter 10 Implementing and Using Classes Study Guide
AP Computer Science Chapter 10 Implementing and Using Classes Study Guide 1. A class that uses a given class X is called a client of X. 2. Private features of a class can be directly accessed only within
More informationObject Oriented Programming is a programming method that combines: Advantage of Object Oriented Programming
Overview of OOP Object Oriented Programming is a programming method that combines: a) Data b) Instructions for processing that data into a self-sufficient object that can be used within a program or in
More informationGraphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub
Lebanese University Faculty of Science Computer Science BS Degree Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub 2 Crash Course in JAVA Classes A Java
More informationAnatomy of a Method. HW3 is due Today. September 15, Midterm 1. Quick review of last lecture. Encapsulation. Encapsulation
Anatomy of a Method September 15, 2006 HW3 is due Today ComS 207: Programming I (in Java) Iowa State University, FALL 2006 Instructor: Alexander Stoytchev Midterm 1 Next Tuesday Sep 19 @ 6:30 7:45pm. Location:
More informationClasses. Classes as Code Libraries. Classes as Data Structures. Classes/Objects/Interfaces (Savitch, Various Chapters)
Classes Classes/Objects/Interfaces (Savitch, Various Chapters) TOPICS Classes Public versus Private Static Data Static Methods Interfaces Classes are the basis of object-oriented (OO) programming. They
More informationObjec,ves. Review: Object-Oriented Programming. Object-oriented programming in Java. What is OO programming? Benefits?
Objec,ves Object-oriented programming in Java Ø Encapsula,on Ø Access modifiers Ø Using others classes Ø Defining own classes Sept 16, 2016 Sprenkle - CSCI209 1 Review: Object-Oriented Programming What
More informationJava How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved.
Java How to Program, 10/e Education, Inc. All Rights Reserved. Each class you create becomes a new type that can be used to declare variables and create objects. You can declare new classes as needed;
More informationMethods. Methods. Mysteries Revealed
Methods Methods and Data (Savitch, Chapter 5) TOPICS Invoking Methods Return Values Local Variables Method Parameters Public versus Private A method (a.k.a. func2on, procedure, rou2ne) is a piece of code
More informationSoftware and Programming 1
Software and Programming 1 Week 9 Lab - Use of Classes and Inheritance 8th March 2018 SP1-Lab9-2018.ppt Tobi Brodie (Tobi@dcs.bbk.ac.uk) 1 Lab 9: Objectives Exercise 1 Student & StudentTest classes 1.
More informationObject Oriented Programming SCJ2153. Class and Object. Associate Prof. Dr. Norazah Yusof
Object Oriented Programming SCJ2153 Class and Object Associate Prof. Dr. Norazah Yusof Classes Java program consists of classes. Class is a template for creating objects. Class normally consists of 3 components:
More informationECOM 2324 COMPUTER PROGRAMMING II
ECOM 2324 COMPUTER PROGRAMMING II Object Oriented Programming with JAVA Instructor: Ruba A. Salamh Islamic University of Gaza 2 CHAPTER 9 OBJECTS AND CLASSES Motivations 3 After learning the preceding
More informationObjectives. Defining Classes and Methods. Objectives. Class and Method Definitions: Outline 7/13/09
Objectives Walter Savitch Frank M. Carrano Defining Classes and Methods Chapter 5 Describe concepts of class, class object Create class objects Define a Java class, its methods Describe use of parameters
More informationby Pearson Education, Inc. All Rights Reserved. 2
Suppose you want to drive a car and make it go faster by pressing down on its accelerator pedal. Before you can drive a car, someone has to design it and build it. A car typically begins as engineering
More information1B1b Classes in Java Part I
1B1b Classes in Java Part I Agenda Defining simple classes. Instance variables and methods. Objects. Object references. 1 2 Reading You should be reading: Part I chapters 6,9,10 And browsing: Part IV chapter
More informationLecture 5: Methods CS2301
Lecture 5: Methods NADA ALZAHRANI CS2301 1 Opening Problem Find the sum of integers from 1 to 10, from 20 to 30, and from 35 to 45, respectively. 2 Solution public static int sum(int i1, int i2) { int
More informationProgramming II (CS300)
1 Programming II (CS300) Chapter 10 Recursion and Search MOUNA KACEM Recursion: General Overview 2 Recursion in Algorithms Recursion is the use of recursive algorithms to solve a problem A recursive algorithm
More informationExample: Fibonacci Numbers
Example: Fibonacci Numbers Write a program which determines F n, the (n + 1)-th Fibonacci number. The first 10 Fibonacci numbers are 0, 1, 1, 2, 3, 5, 8, 13, 21, and 34. The sequence of Fibonacci numbers
More informationClasses and Objects. CGS 3416 Spring 2018
Classes and Objects CGS 3416 Spring 2018 Classes and Objects An object is an encapsulation of data along with functions that act upon that data. It attempts to mirror the real world, where objects have
More informationObjects as a programming concept
Objects as a programming concept IB Computer Science Content developed by Dartford Grammar School Computer Science Department HL Topics 1-7, D1-4 1: System design 2: Computer Organisation 3: Networks 4:
More informationDistributed Systems Recitation 1. Tamim Jabban
15-440 Distributed Systems Recitation 1 Tamim Jabban Office Hours Office 1004 Sunday, Tuesday: 9:30-11:59 AM Appointment: send an e-mail Open door policy Java: Object Oriented Programming A programming
More informationChapter 5 Object-Oriented Programming
Chapter 5 Object-Oriented Programming Develop code that implements tight encapsulation, loose coupling, and high cohesion Develop code that demonstrates the use of polymorphism Develop code that declares
More informationEXAMINATION FOR THE DIPLOMA IN INFORMATION TECHNOLOGY; YEAR 2
FACULTY OF SCIENCE AND TECHNOLOGY EXAMINATION FOR THE DIPLOMA IN INFORMATION TECHNOLOGY; YEAR 2 SAMPLE QUESTION Question 1 A class called TV is required by a programmer who is writing software for a retail
More informationDefining Classes and Methods
Walter Savitch Frank M. Carrano Defining Classes and Methods Chapter 5 ISBN 0136091113 2009 Pearson Education, Inc., Upper Saddle River, NJ. All Rights Reserved Objectives Describe concepts of class, class
More informationCSC 1214: Object-Oriented Programming
CSC 1214: Object-Oriented Programming J. Kizito Makerere University e-mail: jkizito@cis.mak.ac.ug www: http://serval.ug/~jona materials: http://serval.ug/~jona/materials/csc1214 e-learning environment:
More informationC08: Inheritance and Polymorphism
CISC 3120 C08: Inheritance and Polymorphism Hui Chen Department of Computer & Information Science CUNY Brooklyn College 2/26/2018 CUNY Brooklyn College 1 Outline Recap and issues Project progress? Practice
More informationObject Oriented Programming
Object Oriented Programming Digital Urban Visualization. People as Flows. 10.10.2016 ia zuend@arch.ethz.ch treyer@arch.ethz.ch chirkin@arch.ethz.ch Object Oriented Programming? Pertaining to a technique
More informationCOMP 401 Spring 2013 Midterm 1
COMP 401 Spring 2013 Midterm 1 I have not received nor given any unauthorized assistance in completing this exam. Signature: Name: PID: Please be sure to put your PID at the top of each page. This page
More informationProgramming II (CS300)
1 Programming II (CS300) Chapter 10 Recursion and Search MOUNA KACEM mouna@cs.wisc.edu Spring 2019 Recursion: General Overview 2 Recursion in Algorithms Recursion is the use of recursive algorithms to
More informationSee the CS 2704 notes on C++ Class Basics for more details and examples. Data Structures & OO Development I
Polynomial Class Polynomial(); Polynomial(const string& N, const vector& C); Polynomial operator+(const Polynomial& RHS) const; Polynomial operator-(const Polynomial& RHS) const; Polynomial operator*(const
More informationDefining Classes and Methods. Objectives. Objectives 6/27/2014. Chapter 5
Defining Classes and Methods Chapter 5 Objectives Describe concepts of class, class object Create class objects Define a Java class, its methods Describe use of parameters in a method Use modifiers public,
More informationChapter 9 Objects and Classes. Liang, Introduction to C++ Programming, (c) 2007 Pearson Education, Inc. All rights reserved.
Chapter 9 Objects and Classes 1 Objectives Classes & Objects ( 9.2). UML ( 9.2). Constructors ( 9.3). How to declare a class & create an object ( 9.4). Separate a class declaration from a class implementation
More informationDay 2. COMP 1006/1406A Summer M. Jason Hinek Carleton University
Day 2 COMP 1006/1406A Summer 2016 M. Jason Hinek Carleton University today s agenda a quick look back (Monday s class) assignments a1 is due on Monday a2 will be available on Monday and is due the following
More informationPrinciples of Object Oriented Programming. Lecture 4
Principles of Object Oriented Programming Lecture 4 Object-Oriented Programming There are several concepts underlying OOP: Abstract Types (Classes) Encapsulation (or Information Hiding) Polymorphism Inheritance
More informationJava. Classes 3/3/2014. Summary: Chapters 1 to 10. Java (2)
Summary: Chapters 1 to 10 Sharma Chakravarthy Information Technology Laboratory (IT Lab) Computer Science and Engineering Department The University of Texas at Arlington, Arlington, TX 76019 Email: sharma@cse.uta.edu
More informationEEE-425 Programming Languages (2013) 1
2 Learn about class concepts How to create a class from which objects can be instantiated Learn about instance variables and methods How to declare objects How to organize your classes Learn about public
More informationObject Oriented Programming. C++ 6 th Sem, A Div Ms. Mouna M. Naravani
Object Oriented Programming C++ 6 th Sem, A Div 2018-19 Ms. Mouna M. Naravani Object Oriented Programming (OOP) removes some of the flaws encountered in POP. In OOPs, the primary focus is on data rather
More informationBinghamton University. CS-140 Fall Problem Solving. Creating a class from scratch
Problem Solving Creating a class from scratch 1 Recipe for Writing a Class 1. Write the class boilerplate stuff 2. Declare Fields 3. Write Creator(s) 4. Write accessor methods 5. Write mutator methods
More informationCS 2530 INTERMEDIATE COMPUTING
CS 2530 INTERMEDIATE COMPUTING Spring 2018 1-24-2018 Michael J. Holmes University of Northern Iowa Today s topic: Writing classes. 1 Die Objects A die has physical attributes: a specific Number of Sides
More informationUpdates. Office B116E Office Hours : Friday 1 p.m. 2 p.m. Also by appointment Office Hours Purpose:
CS 180 Amit Gupta Updates Office B116E Office Hours : Friday 1 p.m. 2 p.m. Also by appointment gupta75@purdue.edu Office Hours Purpose: Course Material and Recitation No project questions Quizzes I will
More information12/22/11. Java How to Program, 9/e. public must be stored in a file that has the same name as the class and ends with the.java file-name extension.
Java How to Program, 9/e Education, Inc. All Rights Reserved. } Covered in this chapter Classes Objects Methods Parameters double primitive type } Create a new class (GradeBook) } Use it to create an object.
More informationComp 248 Introduction to Programming Chapter 4 & 5 Defining Classes Part B
Comp 248 Introduction to Programming Chapter 4 & 5 Defining Classes Part B Dr. Aiman Hanna Department of Computer Science & Software Engineering Concordia University, Montreal, Canada These slides has
More informationTopic 7: Inheritance. Reading: JBD Sections CMPS 12A Winter 2009 UCSC
Topic 7: Inheritance Reading: JBD Sections 7.1-7.6 1 A Quick Review of Objects and Classes! An object is an abstraction that models some thing or process! Examples of objects:! Students, Teachers, Classes,
More informationCOMP-202: Foundations of Programming. Lecture 9: Classes and Objects Sandeep Manjanna, Summer 2015
COMP-202: Foundations of Programming Lecture 9: Classes and Objects Sandeep Manjanna, Summer 2015 Announcements Assignment 3: Due on 14 th of June at 11:30 pm. Small Software Glitch Costing Huge The spacecraft
More informationRecursion 1. Recursion is the process of defining something in terms of itself.
Recursion 1 Recursion is the process of defining something in terms of itself. A method that calls itself is said to be recursive. Recursion is an alternative form of program control. It is repetition
More informationProgramming Language Concepts Object-Oriented Programming. Janyl Jumadinova 28 February, 2017
Programming Language Concepts Object-Oriented Programming Janyl Jumadinova 28 February, 2017 Three Properties of Object-Oriented Languages: Encapsulation Inheritance Dynamic method binding (polymorphism)
More informationObject Oriented Programming in C#
Introduction to Object Oriented Programming in C# Class and Object 1 You will be able to: Objectives 1. Write a simple class definition in C#. 2. Control access to the methods and data in a class. 3. Create
More informationBasic Object-Oriented Concepts. 5-Oct-17
Basic Object-Oriented Concepts 5-Oct-17 Concept: An object has behaviors In old style programming, you had: data, which was completely passive functions, which could manipulate any data An object contains
More informationCS360 Lecture 5 Object-Oriented Concepts
Tuesday, February 17, 2004 Last Time CS360 Lecture 5 Object-Oriented Concepts On Thursday I introduced the basics of object-oriented programming. We covered: - Creating public classes (each public class
More informationCMSC131. Creating a Datatype Class Continued Exploration of Memory Model. Reminders
CMSC131 Creating a Datatype Class Continued Exploration of Memory Model Reminders The name of the source code file needs to match the name of the class. The name of the constructor(s) need(s) to match
More informationTable of Contents Date(s) Title/Topic Page #s. Chapter 4: Writing Classes 4.1 Objects Revisited
Table of Contents Date(s) Title/Topic Page #s 11/6 Chapter 3 Reflection/Corrections 56 Chapter 4: Writing Classes 4.1 Objects Revisited 57 58-59 look over your Ch 3 Tests and write down comments/ reflections/corrections
More informationObject-Oriented Programming
- oriented - iuliana@cs.ubbcluj.ro Babes-Bolyai University 2018 1 / 56 Overview - oriented 1 2 -oriented 3 4 5 6 7 8 Static and friend elements 9 Summary 2 / 56 I - oriented was initially created by Bjarne
More informationChapter 3 Objects and Classes
Chapter 3 Objects and Classes Topics OO Programming Concepts Creating Objects and Object Reference Variables Constructors Modifiers Instance and Class Variables and Methods Scope of Variables OO Programming
More information