Copyright by Scott GrissomCh 5 Sophisticated Behavior Slide 1 Java Class Library a very large collection of classes for you to use as needed the challenge.

Slides:



Advertisements
Similar presentations
Sequence of characters Generalized form Expresses Pattern of strings in a Generalized notation.
Advertisements

More Sophisticated Behaviour 1 Using library classes to implement more advanced functionality.
Sets and Maps Part of the Collections Framework. 2 The Set interface A Set is unordered and has no duplicates Operations are exactly those for Collection.
Problem Solving 5 Using Java API for Searching and Sorting Applications ICS-201 Introduction to Computing II Semester 071.
Singleton vs utility class  at first glance, the singleton pattern does not seem to offer any advantages to using a utility class  i.e., a utility class.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Java From Control Structures through Data Structures by.
Copyright by Scott GrissomCh 7 Designing Classes Slide 1 Well Designed Classes (Ch 7) Applications are a collection of interacting classes Our Goal It.
Collections & Loops Chapter 5 Copyright © 2012 Pearson Education, Inc.
More sophisticated behaviour Using library classes to implement some more advanced functionality.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Copyright by Scott GrissomCh 1 Objects and Classes Slide 1 Classes and Objects A Class refers to something in general describes a category of items a cookie.
Copyright 2006 by Pearson Education 1 reading: 4.1 Cumulative sum.
More sophisticated behavior Using library classes to implement some more advanced functionality 4.0.
More Sophisticated Behaviour 2 Using library classes to implement more advanced functionality. Also … class ( static ) fields.
Make Sure You Know All This!. Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 2 Objects and Classes.
CSE 373 Data Structures and Algorithms Lecture 18: Hashing III.
More sophisticated behavior Using library classes to implement some more advanced functionality 3.0.
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
More sophisticated behavior Using library classes to implement some more advanced functionality.
Dictionaries Chapter Chapter Contents Specifications for the ADT Dictionary A Java Interface Iterators Using the ADT Dictionary A Directory of Telephone.
CSE 143 Lecture 7 Sets and Maps reading: ; 13.2 slides created by Marty Stepp
Sets and Maps Part of the Collections Framework. The Set interface A Set is unordered and has no duplicates Operations are exactly those for Collection.
Random, Collections & Loops Chapter 5 Copyright © 2012 Pearson Education, Inc.
CS2110: SW Development Methods Textbook readings: MSD, Chapter 8 (Sect. 8.1 and 8.2) But we won’t implement our own, so study the section on Java’s Map.
Collections in Java. Kinds of Collections Collection --a group of objects, called elements –Set-- An unordered collection with no duplicates SortedSet.
(c) University of Washington14-1 CSC 143 Java Collections.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Java Arrays and ArrayLists.
Arrays and ArrayLists in Java L. Kedigh. Array Characteristics List of values. A list of values where every member is of the same type. Each member in.
CIT 590 Intro to Programming First lecture on Java.
More sophisticated behavior Using library classes to implement some more advanced functionality 5.0.
Collections. The Plan ● Why use collections? ● What collections are available? ● How are the collections different? ● Examples ● Practice.
1 TCSS 143, Autumn 2004 Lecture Notes Java Collection Framework: Maps and Sets.
Lecture 131 CS110 Lecture 13 Thursday, March 11, 2004 Announcements –hw5 due tonight –Spring break next week –hw6 due two weeks from tonight Agenda –questions.
10-Nov-15 Java Object Oriented Programming What is it?
CSC 142 P 1 CSC 142 Collections [Reading: Chapter 10]
Chapter 10 Defining Classes. The Internal Structure of Classes and Objects Object – collection of data and operations, in which the data can be accessed.
Goals for Today 1  Multiton  maps  static factory methods.
Mixing Static and Non-static
Copyright 2010 by Pearson Education Homework 9: Critters (cont.) reading: HW9 spec.
Lecture 121 CS110 Lecture 12 Tuesday, March 9, 2004 Announcements –hw5 due Thursday –Spring break next week Agenda –questions –ArrayList –TreeMap.
COP INTERMEDIATE JAVA Designing Classes. Class Template or blueprint for creating objects. Their definition includes the list of properties (fields)
Copyright by Scott GrissomCh 2 Class Definition Slide 1 Class Structure public class BankAccount{ fields constructor(s) methods } Sample Code Ticket Machine.
More sophisticated behavior Using library classes to implement some more advanced functionality 5.0.
Chapter 4 Grouping Objects. Flexible Sized Collections  When writing a program, we often need to be able to group objects into collections  It is typical.
1 COS 260 DAY 10 Tony Gauvin. 2 Agenda Questions? 4 th Mini quiz Today –Chapter 4 Assignment 2 Due Capstone Discussion Proposals Due Oct 15 No class on.
Recitation 5 Enums and The Java Collections classes/interfaces 1.
Composition When one class contains an instance variable whose type is another class, this is called composition. Instead of inheritance, which is based.
CS1054: Lecture 11 More Sophisticated Behavior (contd..)
CSE 143 Lecture 2 More ArrayList ; classes and objects reading: 10.1; slides created by Marty Stepp and Hélène Martin
Sets and Maps Part of the Collections Framework. 2 The Set interface A Set is unordered and has no duplicates Operations are exactly those for Collection.
CSSE 375 Organizing Data – Part 1 Shawn and Steve Q1.
Copyright 2010 by Pearson Education Homework 9: Critters (cont.) reading: HW9 spec.
1 Maps, Stacks and Queues Maps Reading:  2 nd Ed: 20.4, 21.2, 21.7  3 rd Ed: 15.4, 16.2, 16.7 Additional references: Online Java Tutorial at
Terms and Rules II Professor Evan Korth New York University (All rights reserved)
Collections Dwight Deugo Nesa Matic
CSE 373: Data Structures and Algorithms Lecture 16: Hashing III 1.
CSE 143 Lecture 11: Sets and Maps reading:
Object-Oriented Design Chapter 7 1. Objectives You will be able to Use the this reference in a Java program. Use the static modifier for member variables.
Review. Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Objects and Classes Objects and Classes –State.
BlueJ Chapter 5 More sophisticated behavior: Library classes and documentation.
Java Arrays and ArrayLists COMP T1 #5
Object-Oriented Design
More Sophisticated Behavior
University of Central Florida COP 3330 Object Oriented Programming
More sophisticated behavior
CSE 143 Lecture 9 References and Linked Nodes reading: 3.3; 16.1
ArrayLists 22-Feb-19.
CSE 143 Lecture 5 References and Linked Nodes
Tonga Institute of Higher Education
Web Design & Development Lecture 6
Presentation transcript:

copyright by Scott GrissomCh 5 Sophisticated Behavior Slide 1 Java Class Library a very large collection of classes for you to use as needed the challenge is to know which ones and when reading and understanding the API is critical available through BlueJ or the web demo for Strings import constructors methods

copyright by Scott GrissomCh 5 Sophisticated Behavior Slide 2 Strings methods int length() boolean contains(String) boolean startsWith(String) String [] split(String) String toLowerCase()

copyright by Scott GrissomCh 5 Sophisticated Behavior Slide 3 Randomness (5.4) computers generate pseudo-random values that can be repeatable if necessary source code Random myRand = new Random(); val = myRand.nextInt(); val = myRand.nextInt(6); result = myRand.nextBoolean(); Group Activities generate a random response from “yes”, “no”, “it depends” generate a random number between 1 and N generate a random number between min and max

copyright by Scott GrissomCh 5 Sophisticated Behavior Slide 4 TechSupport this book project attempts to automate technical phone support by pretending to respond to customer questions the classes inputReader - reads the customer question from the key board Resonder - prints a random response SupportSystem - continues processing requests until ‘bye’ source code refer to book

copyright by Scott GrissomCh 5 Sophisticated Behavior Slide 5 HashMap (5.6) A collection of paired data (key, value) the key is used to access the value (instead of an index) keys must be unique examples name and phone number ID and name operations put(key, value) value = get(key) size() isEmpty() clear() Take note duplicate keys replace the previous ones null is returned if no key is found source code HashMap guestList; guestList = new HashMap (); guestList.put(“123”,”Henry”); name = guestList.get(“123”);

copyright by Scott GrissomCh 5 Sophisticated Behavior Slide 6 HashSet (5.7) similar to an arraylist only one copy of an item is allowed the order of items is undefined Tech Support System see the code

copyright by Scott GrissomCh 5 Sophisticated Behavior Slide 7 Public / private (5.11) Access modifiers define the visibility of methods and fields public items can be seen by any class private items can only be seen from within the class fields should always be private to protect the data information hiding methods are often public but can be private if there is no need for the public to have access

copyright by Scott GrissomCh 5 Sophisticated Behavior Slide 8 Constants fields whose values can not be changed compiler will prevent accidental changes private final int MAX = 10; class variables exist at the class level private static int count; these two modifiers are often used together