Abstract Data Types and Java Classes

Slides:



Advertisements
Similar presentations
Classes And Objects II. Recall the LightSwitch Class class LightSwitch { boolean on = true; boolean isOn() { return on; } void switch() { on = !on; }
Advertisements

Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
Picture It Very Basic Game Picture Pepper. Original Game import java.util.Scanner; public class Game { public static void main() { Scanner scan=new Scanner(System.in);
The Point Class public class Point { public double x; public double y; public Point(double x0, double y0) { x = x0; y = y0; } public double distance(Point.
Copyright 2008 by Pearson Education Building Java Programs Chapter 8 Lecture 8-3: Encapsulation, toString reading: self-checks: #13-18,
Pointers Prasun Dewan Comp 114.
INTERFACES IN JAVA 1.Java Does not support Multiple Inheritance directly. Multiple inheritance can be achieved in java by the use of interfaces. 2.We need.
Esempio Polimorfismo1 // Definition of abstract base class Shape #ifndef SHAPE_H #define SHAPE_H class Shape { public: virtual double area() const { return.
Lecture 28: Abstract Classes & Inheritance Announcements & Review Lab 8 Due Thursday Image and color effects with 2D arrays Read: –Chapter 9 Cahoon & Davidson.
Using interfaces Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling How would you find the maximum.
Unit 261 Introduction to Searching and Sorting Comparable Interface Comparator Interface Algorithm Complexity Classes Exercises.
CS 106 Introduction to Computer Science I 04 / 16 / 2010 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 11 / 15 / 2006 Instructor: Michael Eckmann.
Inheritance and interfaces A class C1 is derived from class C2, then C1 is called subclass, and C2 is called superclass Superclass-parent, base class Subclass.
CS 2511 Fall Features of Object Oriented Technology  Abstraction Abstract class Interfaces  Encapsulation Access Specifiers Data Hiding  Inheritance.
Object Oriented Programming Concepts OOP – reasoning about a program as a set of objects rather than as a set of actions Object – a programming entity.
Week 3 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
1 Object-Oriented Software Engineering CS Interfaces Interfaces are contracts Contracts between software groups Defines how software interacts with.
Features of Object Oriented Programming Lec.4. ABSTRACTION AND ENCAPSULATION Computer programs can be very complex, perhaps the most complicated artifact.
Introducing Objects. Structure  Objects have two parts: Instance Variables (attributes, adjectives) Instance Variables (attributes, adjectives) private.
© A+ Computer Science - public Triangle() { setSides(0,0,0); } Constructors are similar to methods. Constructors set the properties.
AP Computer Science A – Healdsburg High School 1 Interfaces, Abstract Classes and the DanceStudio - Similarities and Differences between Abstact Classes.
P Chapter 2 introduces Object Oriented Programming. p OOP is a relatively new approach to programming which supports the creation of new data types and.
Object-Oriented Programming Developing an Application.
1 OOP : main concepts Polymorphism. 2 OOP : main concepts  The main concepts:  In a superclass –public members Accessible anywhere program has a reference.
CSC 205 Java Programming II Defining & Implementing Classes.
Chapter 5 Objects and Classes Inheritance. Solution Assignments 3 & 4 Review in class…..
Chapter 3 Collections. Objectives  Define the concepts and terminology related to collections  Explore the basic structures of the Java Collections.
Chapter 8 Class Inheritance and Interfaces F Superclasses and Subclasses  Keywords: super F Overriding methods  The Object Class  Modifiers: protected,
Application development with Java Lecture 21. Inheritance Subclasses Overriding Object class.
Access Modifiers Control which classes use a feature Only class-level variables may be controlled by access modifiers Modifiers 1. public 2. protected.
1 Inheritance and Subclasses. 2 Inheritance Often we create very similar classes –Different types of triangles: equilateral, isosceles, etc. –Different.
(c) University of Washington06-1 CSC 143 Java Inheritance Tidbits.
Interfaces, Abstract Classes, and Polymorphism. What Is an Interface? An interface is the set of public methods in a class Java provides the syntax for.
CSI 3125, Preliminaries, page 1 Inheritance. CSI 3125, Preliminaries, page 2 Inheritance Using inheritance, can create a general class that defines traits.
Powerpoint slides from A+ Computer Science Modified by Mr. Smith for his course.
1 Chapter 8 Class Inheritance and Interfaces F Superclasses and Subclasses  Keywords: super F Overriding methods  The Object Class  Modifiers: protected,
College Board Topics – A.P. Computer Science A Program Design - Read and understand a problem's description, purpose, and goals; Apply data abstraction.
Inheritance INHERITANCE: extend existing classes by adding or redefining methods, and adding instance fields Suppose we have a class Vehicle: public class.
CSE 1020:Using Objects Mark Shtern 1-1. Summary Read API Method binding and overloading Development process Input validation Assert 1-2.
CMSC 202 Polymorphism 2 nd Lecture. Aug 6, Topics Constructors and polymorphism The clone method Abstract methods Abstract classes.
Powerpoint slides from A+ Computer Science Modified by Mr. Smith for his course.
Programming in Java Transitioning from Alice. Becomes not myFirstMethod but …. public static void main (String[] arg) { // code for testing classes goes.
Objects and Classes. F OO Programming Concepts F Creating Objects and Object Reference Variables –Differences between primitive data type and object type.
יסודות מדעי המחשב – תרגול 6
Objects as a programming concept
Lecture 12 Inheritance.
03/10/14 Inheritance-2.
Polymorphism 2nd Lecture
Chapter 8 Classes and Objects
CS 302 Week 11 Jim Williams, PhD.
Unit-2 Objects and Classes
Polymorphism 2nd Lecture
null, true, and false are also reserved.
Introduction to Java Programming
The Language Package.
CSE 1030: Implementing Mixing static and non-static features
CSE 1030: Implementing Non-Static Features
© A+ Computer Science - OOP © A+ Computer Science -
مظفر بگ محمدی دانشگاه ایلام
مظفر بگ محمدی دانشگاه ایلام
Kinds of methods accessor: A method that lets clients examine object state. Examples: distance, distanceFromOrigin often has a non-void return type mutator: A.
Chapter 8 Class Inheritance and Interfaces
Classes and Objects B.Ramamurthy 5/9/2019 B.Ramamurthy.
Introduction to Computer Science and Object-Oriented Programming
Building Java Programs
Day 11 The Last Week!.
Presentation transcript:

Abstract Data Types and Java Classes B.Ramamurthy 11/14/2018 B.Ramamurthy

Introduction Last class we developed a Rectangle interface and an implementation for it. We will examine some more standard methods to be added to a class. Also look into creating packages. Your assignment: Study the Throttle class defined in your text pages 36-56, esp. p.45,46 (design and code) 11/14/2018 B.Ramamurthy

Topics of Discussion Throttle class : specification, implementation and testing. Packages Location class Specialty: equals method and clone method Examples 11/14/2018 B.Ramamurthy

Throttle Throttle int top; int position; //constructor public Throttle (int size); // accessor method public double getFlow(); //predicate method public boolean isOn(); // service methods public void shift(int amount); public void shutOff(); 11/14/2018 B.Ramamurthy

Location (class) Location class is illustrates two important features that you should implement in your classes; equals method and clone method. 11/14/2018 B.Ramamurthy

Location Location double x; double y; Location (double xInit, double yInit); Object clone(); static double distance (Location p1, Location p2); boolean equals(Object obj); double getX(); double getY(); static Location midPoint(Location P1, Location p2); void rotate90(); void shift(double xAmt, double yAmt); String toString(); 11/14/2018 B.Ramamurthy