Wednesday Notecards What’s your credit card number?

Slides:



Advertisements
Similar presentations
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.
Advertisements

Computer Science 209 Software Development Equality and Comparisons.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 11: Sorting and Searching  Searching Linear Binary  Sorting.
© 2006 Pearson Addison-Wesley. All rights reserved16-1 Methods in the List Interface (Part 1 of 16)
Binary Search Trees CMSC 132 Chapter 8.1 Nelson Padua-Perez Bill Pugh.
Slides prepared by Rose Williams, Binghamton University ICS201 Lecture 24 : Collections King Fahd University of Petroleum & Minerals College of Computer.
Collections The objectives of this chapter are: To outline the Collections infrastructure in Java To describe the various collection classes To discuss.
CSE 143 Lecture 14 Interfaces; Abstract Data Types (ADTs) reading: 9.5, 11.1; 16.4 slides created by Marty Stepp
Building Java Programs Interfaces, Comparable reading: , 16.4, 10.2.
Copyright 2008 by Pearson Education Building Java Programs Chapter 9 Lecture 9-4: Interfaces reading: self-check: exercises: #11.
Topic 25 - more array algorithms 1 "To excel in Java, or any computer language, you want to build skill in both the "large" and "small". By "large" I mean.
CSE 143 Lecture 15 Binary Search; Comparable reading: 13.2; 10.2 slides created by Marty Stepp
Java 2 Collections Bartosz Walter Software Engineering II.
CSE 143 Lecture 6 Interfaces; Complexity (Big-Oh) reading: 9.5, 11.1, slides created by Marty Stepp
EE 422C Interfaces Day 5. 2 Announcements SVN has Project 2. –Partly due next week. –SVN update to get it in your repository. See Piazza for Grocery List.
Cs205: engineering software university of virginia fall 2006 Subtyping and Inheritance David Evans Quiz Friday: classes through.
CSE 143 Lecture 2 More ArrayList ; classes and objects reading: 10.1; slides created by Marty Stepp and Hélène Martin
University of Limerick1 Collections The Collection Framework.
1 CSE 331 Comparing objects; Comparable, compareTo, and Comparator slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R.
Building Java Programs Chapter 13 Searching and Sorting Copyright (c) Pearson All rights reserved.
Building Java Programs Chapter 13 Sorting reading: 13.3, 13.4.
Building Java Programs Interfaces reading: , 16.4.
CSE 143 Lecture 14 Interfaces; Abstract Data Types (ADTs)
Lecture 23:More on Interfaces
Lecture 13: Interfaces, Comparable reading: , 16.4, 10.2
Collections.
Interfaces.
Lecture 1: Welcome to CSE 373
slides created by Marty Stepp and Hélène Martin
Interfaces EE 422C.
Collections class Method name Description binarySearch(list, value)
CSE 143 Lecture 14 Searching and Comparable reading: ; 10.2
Object Oriented Programming (OOP) LAB # 8
Lecture 14: binary search and complexity reading:
TCSS 143, Autumn 2004 Lecture Notes
Building Java Programs
slides adapted from Marty Stepp and Hélène Martin
Building Java Programs
Programming in C# Comparison (Sorting)
Interfaces CS163 Fall 2018.
CSE 143 Lecture 6 Interfaces; Complexity (Big-Oh)
Lecture 15: binary search reading:
CSE 154 Sorting reading: 13.3, 13.4
Collections in Java The objectives of this lecture are:
Lecture 5: complexity reading:
slides created by Marty Stepp
Collections class Method name Description binarySearch(list, value)
CSE 143 Lecture 16 (A) Searching and Comparable
Shapes Consider the task of writing classes to represent 2D shapes such as Circle, Rectangle, and Triangle. Certain operations are common to all shapes:
slides created by Marty Stepp and Ethan Apter
slides created by Marty Stepp
CSE 143 Sorting reading: 13.3, 13.4.
Lecture 8: Complex Linked List Code reading: 16.2 – 16.3
Based on slides by Alyssa Harding & Marty Stepp
Building Java Programs Chapter 13
Binary search (13.1) binary search: Locates a target value in a sorted array/list by successively eliminating half of the array from consideration. How.
slides created by Marty Stepp and Hélène Martin
Searching.
CSE 373 Implementing a Stack Reading: Weiss Ch. 3; 3.6; 1.5
CSE 373 Data Structures and Algorithms
CSE 373 Sorting 1: Bogo Sort, Stooge Sort, Bubble Sort
slides created by Marty Stepp
Podcast Ch22a Title: Array-based Binary Trees
CSE 143 Lecture 8 Iterators; Comparable reading: 11.2; 10.2
Collections class Method name Description binarySearch(list, value)
CSE 143 Lecture 6 interfaces; eclipse; testing
Topic 25 - more array algorithms
CSE 373: Data Structures and Algorithms
CSE 143 Lecture 14 Searching and Comparable reading: ; 10.2
CSE 373: Data Structures and Algorithms
Presentation transcript:

Wednesday Notecards What’s your credit card number? In contains, how would we get it to return false if either the left or the right returned false? Use &&, you can always try writing out truth tables “I can’t be-LEAF this class is almost over” I guarantree that I feel the same way What type of questions should we go to office hours for instead of the IPL? Both are good for help on HW or understanding concepts Office hours are a bit better for more 1 on 1 time Monday hours aren’t super crowded

Wednesday Notecards

Collections class Method name Description binarySearch(list, value) returns the index of the given value in a sorted list (< 0 if not found) copy(listTo, listFrom) copies listFrom's elements to listTo emptyList(), emptyMap(), emptySet() returns a read-only collection of the given type that has no elements fill(list, value) sets every element in the list to have the given value max(collection), min(collection) returns largest/smallest element replaceAll(list, old, new) replaces an element value with another reverse(list) reverses the order of a list's elements shuffle(list) arranges elements into a random order sort(list) arranges elements into ascending order

The compareTo method (10.2) The standard way for a Java class to define a comparison function for its objects is to define a compareTo method. Example: in the String class, there is a method: public int compareTo(String other) A call of A.compareTo(B) will return: a value < 0 if A comes "before" B in the ordering, a value > 0 if A comes "after" B in the ordering, 0 if A and B are considered "equal" in the ordering.

Interfaces (9.5) interface: A list of methods that a class can promise to implement. Inheritance gives you an is-a relationship and code sharing. A Lawyer can be treated as an Employee and inherits its code. Interfaces give you an is-a relationship without code sharing. A Rectangle object can be treated as a Shape but inherits no code. Analogous to non-programming idea of roles or certifications: "I'm certified as a CPA accountant. This assures you I know how to do taxes, audits, and consulting." "I'm 'certified' as a Shape, because I implement the Shape interface. This assures you I know how to compute my area and perimeter."

Comparable (10.2) public interface Comparable<E> { public int compareTo(E other); } A class can implement the Comparable interface to define a natural ordering function for its objects. A call to your compareTo method should return: a value < 0 if the this object comes "before" other one, a value > 0 if the this object comes "after" other one, 0 if the this object is considered "equal" to other.