Data Structures Using Java1 Chapter 1 Software Engineering Principles and Java Classes.

Slides:



Advertisements
Similar presentations
Alice in Action with Java Chapter 6 Events. Alice in Action with Java2 Objectives Create new events in Alice Create handler methods for Alice events Use.
Advertisements

The University of Akron Summit College
Data Structures Using Java1 Chapter 3 Array-Based Lists.
Chapter 7 User-Defined Methods. Chapter Objectives  Understand how methods are used in Java programming  Learn about standard (predefined) methods and.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie July 8, 2005.
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming The software development method algorithms.
1 Chapter 6 Object-Oriented Software Design and Implementation.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 11: Classes and Data Abstraction.
Chapter 8 User-Defined Classes and ADTs. Chapter Objectives Learn about classes Learn about private, protected, public, and static members of a class.
C++ Programming: From Problem Analysis to Program Design, Second Edition Chapter 13: Inheritance and Composition.
Chapter 1 Principles of Programming and Software Engineering.
Chapter 11: Classes and Data Abstraction
Software Engineering Principles and C++ Classes
C++ Programming: Program Design Including Data Structures, Fifth Edition Chapter 12: Inheritance and Composition.
Chapter 8: User-Defined Classes and ADTs J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
Data Structures Using C++1 Chapter 1 Software Engineering Principles and C++ Classes.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
COMP 14 Introduction to Programming Miguel A. Otaduy May 24, 2004.
Chapter 11: Inheritance and Polymorphism Java Programming: Program Design Including Data Structures Program Design Including Data Structures.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Chapter 6: Graphical User Interface (GUI) and Object-Oriented Design (OOD) J ava P rogramming: Program Design Including Data Structures Program Design.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 13: Inheritance and Composition.
Data Structures Using C++ 2E Chapter 3 Pointers and Array-Based Lists.
Chapter 11: Inheritance and Composition. Objectives In this chapter, you will: – Learn about inheritance – Learn about derived and base classes – Redefine.
Chapter 11 Inheritance and Composition. Chapter Objectives Learn about inheritance Learn about subclasses and superclasses Explore how to override the.
An Introduction to Java Chapter 11 Object-Oriented Application Development: Part I.
Software Life Cycle Requirements and problem analysis. –What exactly is this system supposed to do? Design –How will the system solve the problem? Coding.
Chapter 11: Classes and Data Abstraction. C++ Programming: Program Design Including Data Structures, Fourth Edition2 Objectives In this chapter, you will:
Data Structures Using C++1 Chapter 1 -Software Engineering Principles -ADT and Classes.
Chapter 8: User-Defined Classes and ADTs
Data Structures Using C++1 Chapter 1 Software Engineering Principles and C++ Classes.
Data Structures Using Java1 Chapter 2 Inheritance and Exception Handling.
Software Engineering Review CS 244 Brent M. Dingle, Ph.D. Game Design and Development Program Department of Mathematics, Statistics, and Computer Science.
CSCI 1100/1202 April 1-3, Program Development The creation of software involves four basic activities: –establishing the requirements –creating.
Data Structures Using C++ 2E
Java Programming: From Problem Analysis to Program Design, 3e Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Chapter 8: User-Defined Classes and ADTs J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 12: Classes and Data Abstraction.
Chapter 10: Classes and Data Abstraction. Objectives In this chapter, you will: Learn about classes Learn about private, protected, and public members.
Java Programming: From Problem Analysis to Program Design, Second Edition1 Lecture 5 Objectives  Learn about basic GUI components.  Explore how the GUI.
CSI 1340 Introduction to Computer Science II Chapter 1 Software Engineering Principles.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 13: Inheritance and Composition.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 11: Classes and Data Abstraction.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 12: Classes and Data Abstraction.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 11: Classes and Data Abstraction.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 05: Classes and Data Abstraction.
Chapter 11: Inheritance and Composition. Introduction Two common ways to relate two classes in a meaningful way are: – Inheritance (“is-a” relationship)
Chapter 10: Classes and Data Abstraction. Classes Object-oriented design (OOD): a problem solving methodology Objects: components of a solution Class:
Chapter 2 Principles of Programming and Software Engineering.
Data Structures Using Java1 Chapter 1 Software Engineering Principles and Java Classes.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 11: Classes and Data Abstraction.
1 CS 132 Spring 2008 Chapter 1 Software Engineering Principles and C++ Classes.
Object Based Programming Chapter 8. 2 Contrast ____________________ Languages –Action oriented –Concentrate on writing ________________ –Data supports.
Java Programming: Guided Learning with Early Objects Chapter 9 Inheritance and Polymorphism.
Principles of Programming & Software Engineering
C++ Plus Data Structures
Java Programming: Guided Learning with Early Objects
Principles of Programming and Software Engineering
About the Presentations
Java Programming: From Problem Analysis to Program Design,
User-Defined Classes and ADTs
Chapter 8: User-Defined Classes and ADTs
User-Defined Classes and ADTs
Review CSE116 2/21/2019 B.Ramamurthy.
Chapter 8 Classes User-Defined Classes and ADTs
Chapter 11: Inheritance and Composition
Presentation transcript:

Data Structures Using Java1 Chapter 1 Software Engineering Principles and Java Classes

Data Structures Using Java2 Chapter Objectives Learn about software engineering principles Discover what an algorithm is and explore problem-solving techniques Become aware of structured design and object- oriented design programming methodologies Learn about user-defined classes Learn about private, protected, and public members of a class

Data Structures Using Java3 Chapter Objectives Explore how classes are implemented Become aware of Unified Modeling Language (UML) notation Examine constructors and destructors Learn about the abstract data type (ADT) Explore how classes are used to implement ADT

Data Structures Using Java4 Software Life Cycle Life cycle: the many phases a program goes through from the time it is conceived until the time it is retired Three fundamental stages of a program –Development –Use –Maintenance

Data Structures Using Java5 Software Development Phase Analysis –Understand problem –Requirements analysis –Data analysis –Divide problem into subproblems and perform analysis

Data Structures Using Java6 Software Development Phase Design –Algorithm –Structured design Divide problem into subproblems and analyze each subproblem –Object-oriented design Identify components (objects) which form the basis of solution Determine how these objects interact with one another

Data Structures Using Java7 Software Development Phase Three basic principles of object-oriented design (OOD) –Encapsulation: ability to combine data and operations in a single unit –Inheritance: ability to create new data types from existing data types –Polymorphism: ability to use the same expression to denote different operations

Data Structures Using Java8 Software Development Phase Implementation –Write and compile programming code to implement classes and functions discovered in design phase

Data Structures Using Java9 Software Development Phase Testing and Debugging –Test the correctness of the program to make sure it does what it is supposed to do –Find and fix errors –Run program through series of specific tests, test cases

Data Structures Using Java10 Software Development Phase Testing and Debugging –Black-box testing: test based on inputs and outputs not the internal working of the algorithm or function –White-box testing: relies on the internal structure and implementation of a function or algorithm; ensures that every part of the function or algorithm executes at least once

Data Structures Using Java11 Algorithm Analysis: The Big-O Notation

Data Structures Using Java12 Algorithm Analysis: The Big-O Notation

Data Structures Using Java13 Algorithm Analysis: The Big-O Notation

Data Structures Using Java14 Algorithm Analysis: The Big-O Notation

Data Structures Using Java15 Algorithm Analysis: The Big-O Notation Definition: Let f be a function of n.The term “asymptotic” means the study of the function f as n becomes larger and larger without bound.

Data Structures Using Java16 Algorithm Analysis: The Big-O Notation

Data Structures Using Java17 Classes class: reserved word; collection of a fixed number of components Components: member of a class Members accessed by name Class categories/modifiers –Private –Protected –public

Data Structures Using Java18 Classes private: members of class not accessible outside class public: members of class accessible outside class Class members: can be methods or variables Variable members declared like any other variables

Data Structures Using Java19 Syntax General syntax for defining a class: modifier(s) class ClassIdentifier modifier(s) { classMembers } General syntax for using the operator new: new className() or new className(argument1, argument2,..., argumentN)

Data Structures Using Java20 Classes Syntax to access data member of class object or method: referenceVariableName.memberName Shallow copying: two or more reference variables of the same type point to the same object Deep copying: each reference variable refers to its own object

Data Structures Using Java21 Constructors Guarantee that data members are initialized when object is declared Automatically execute when class object created Name of constructor is name of class More than one constructor can be present in one class Default constructor: constructor without parameters

Data Structures Using Java22 The Copy Constructor Executes when an object is instantiated Initialized using an existing object Syntax public ClassName(ClassName otherObject)

Data Structures Using Java23 UML Diagram

Data Structures Using Java24 UML Diagram Top box: Name of class Middle box: data members and their data types Bottom box: member methods’ names, parameter list, return type of method + means public method - means private method # means protected method

Data Structures Using Java25 Example: class Clock myClock = new Clock(); yourClock = new Clock(9,35,15);

Data Structures Using Java26 Example: class Clock

Data Structures Using Java27 Example: class Clock

Data Structures Using Java28 The Method toString Public value-returning method Takes no parameters Returns address of String object Output using print and println methods Default definition creates String with name of object’s class name followed by hash code of object

Data Structures Using Java29 The Modifier Static In method heading, specifies that method can be invoked by using name of class If used to declare data member, data member invoked by using class name Static data members of class exist even when no object of class type instantiated Static variables are initialized to their default values

Data Structures Using Java30 static Data Members of a Class Illustrate illusObject1 = new Illustrate(3); Illustrate illusObject2 = new Illustrate(5);

Data Structures Using Java31 Finalizers Automatically execute when class object goes out of scope Have no parameters Only one finalizer per class Name of finalizer: finalize

Data Structures Using Java32 Creating Packages Can create packages using reserved word package –Define the class to be public (If class not public it can only be used within package) –Choose name for package. Organize package (create subdirectories)

Data Structures Using Java33 The Reference this Refers to instance variables and methods of a class Used to implement cascaded method calls

Data Structures Using Java34 Inner Classes Defined within other classes Can be either a complete class definition or anonymous inner class definition Used to handle events

Data Structures Using Java35 Abstract Data Types Definition: A data type that specifies the logical properties without the implementation details

Data Structures Using Java36 Programming Example: Candy Machine (Problem Statement) A common place to buy candy is from a candy machine. A new candy machine is bought for the gym, but it is not working properly. The machine sells candies, chips, gum, and cookies. You have been asked to write a program for this candy machine so that it can be put into operation. The program should do the following: 1. Show the customer the different products sold by the candy machine. 2. Let the customer make the selection. 3. Show the customer the cost of the item selected. 4. Accept money from the customer. 5. Release the item.

Data Structures Using Java37 Programming Example: Candy Machine (Input and Output) Input –Item Selection –Cost of Item Output –The selected item

Data Structures Using Java38 Programming Example: Candy Machine Components –Cash Register –Several Dispensers

Data Structures Using Java39 Programming Example: Candy Machine

Data Structures Using Java40 Programming Example: Candy Machine

Data Structures Using Java41 Programming Example: Candy Machine Object chips

Data Structures Using Java42 Programming Example: Candy Machine Sample Run: In this sample run, the user input is shaded. *** Welcome to Shelly's Candy Shop *** To select an item, enter 1 for Candy 2 for Chips 3 for Gum 4 for Cookies 9 to exit 1 Please deposit 50 cents 50 Collect your item at the bottom and enjoy.

Data Structures Using Java43 Object-Oriented Design Simplified methodology 1. Write down detailed description of problem 2. Identify all (relevant) nouns and verbs 3. From list of nouns, select objects 4. Identify data components of each object 5. From list of verbs, select operations

Data Structures Using Java44 Object-Oriented Design Example Problem Statement –Write a program to input the dimensions of a cylinder and calculate and print the surface area and volume Nouns –Dimensions, surface area, volume, cylinder

Data Structures Using Java45 Chapter Summary Software Life Cycle –Development, Use, Maintenance Algorithm Analysis: The Big-O Notation Classes UML Diagram Constructors, Destructors Abstract Data Types

Data Structures Using Java46 Chapter Summary Software Development Phase –Analysis –Design Structured design Object-oriented design –Encapsulation, Inheritance, Polymorphism –Implementation –Testing and Debugging