Slides adapted from Alex Mariakakis, with material from Krysta Yousoufian, Mike Ernst, Kellen Donohue Section 5: HW6 and Interfaces.

Slides:



Advertisements
Similar presentations
CSE 390B: Graph Algorithms Based on CSE 373 slides by Jessica Miller, Ruth Anderson 1.
Advertisements

Java Review Interface, Casting, Generics, Iterator.
Graphs CSC 220 Data Structure. Introduction One of the Most versatile data structures like trees. Terminology –Nodes in trees are vertices in graphs.
Graph Searching CSE 373 Data Structures Lecture 20.
GRAPHS AND GRAPH TRAVERSALS 9/26/2000 COMP 6/4030 ALGORITHMS.
© 2006 Pearson Addison-Wesley. All rights reserved14 A-1 Chapter 14 excerpts Graphs (breadth-first-search)
try { Assert(Life. Real); Assert(Life
Graphs CS3240, L. grewe.
CS 106 Introduction to Computer Science I 04 / 11 / 2008 Instructor: Michael Eckmann.
Lecture 17 Abstract classes Interfaces The Comparable interface Event listeners All in chapter 10: please read it.
CS 106 Introduction to Computer Science I 04 / 16 / 2010 Instructor: Michael Eckmann.
Graphs & Graph Algorithms Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
16-Aug-15 Air Force Institute of Technology Electrical and Computer Engineering Object-Oriented Programming in Java Topic : Interfaces, Copying/Cloning,
CSE 331 Software Design & Implementation Hal Perkins Autumn 2012 Java Classes, Interfaces, and Types 1.
Chapter 6 Class Inheritance F Superclasses and Subclasses F Keywords: super F Overriding methods F The Object Class F Modifiers: protected, final and abstract.
Implementing Stacks Ellen Walker CPSC 201 Data Structures Hiram College.
Tree Searching Breadth First Search Dept First Search.
MA/CSSE 473 Day 12 Insertion Sort quick review DFS, BFS Topological Sort.
1 Object-Oriented Software Engineering CS Interfaces Interfaces are contracts Contracts between software groups Defines how software interacts with.
JAVA COLLECTIONS LIBRARY School of Engineering and Computer Science, Victoria University of Wellington COMP T2, Lecture 2 Marcus Frean.
Warmup A programmer’s wife tells him, “Would you mind going to the store and picking up a loaf of bread? Also, if they have eggs, get a dozen.” The programmer.
Chapter 2 Introducing Interfaces Summary prepared by Kirk Scott.
CSE 12 – Basic Data Structures Cynthia Bailey Lee Some slides and figures adapted from Paul Kube’s CSE 12 CS2 in Java Peer Instruction Materials by Cynthia.
1/20/03A2-1 CS494 Interfaces and Collection in Java.
Graphs. Made up of vertices and arcs Digraph (directed graph) –All arcs have arrows that give direction –You can only traverse the graph in the direction.
Chapter 3 Inheritance and Polymorphism Goals: 1.Superclasses and subclasses 2.Inheritance Hierarchy 3.Polymorphism 4.Type Compatibility 5.Abstract Classes.
COMP261 Lecture 6 Dijkstra’s Algorithm. Connectedness Is this graph connected or not? A Z FF C M N B Y BB S P DDGG AA R F G J L EE CC Q O V D T H W E.
SECTION 2: CODE REASONING + PROGRAMMING TOOLS slides borrowed and adapted from Alex Mariakis and CSE 390a.
A programmer’s wife tells him, “Would you mind going to the store and picking up a loaf of bread. Also, if they have eggs, get a dozen.” The programmer.
Inheritance. Inheritance - Introduction Idea behind is to create new classes that are built on existing classes – you reuse the methods and fields and.
Application development with Java Lecture 21. Inheritance Subclasses Overriding Object class.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 13: Graphs Data Abstraction & Problem Solving with C++
Trees, Binary Search Trees, Balanced Trees, Graphs Graph Fundamentals Telerik Algo Academy
Depth-First Search Lecture 21: Graph Traversals
© 2006 Pearson Addison-Wesley. All rights reserved 14 A-1 Chapter 14 Graphs.
Interfaces F What is an Interface? F Creating an Interface F Implementing an Interface F What is Marker Interface?
Lecture 8: Advanced OOP Part 2. Overview Review of Subtypes Interfaces Packages Sorting.
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
SLIDES ADAPTED FROM ALEX MARIAKAKIS, WITH MATERIAL FROM KRYSTA YOUSOUFIAN, MIKE ERNST, KELLEN DONOHUE Section 5: HW6 and Interfaces Justin Bare and Deric.
JAVA COLLECTIONS LIBRARY School of Engineering and Computer Science, Victoria University of Wellington COMP T2, Lecture 2 Marcus Frean.
Justin Bare and Deric Pang with material from Erin Peach, Nick Carney, Vinod Rathnam, Alex Mariakakis, Krysta Yousoufian, Mike Ernst, Kellen Donohue Section.
1 Chapter 8 Class Inheritance and Interfaces F Superclasses and Subclasses  Keywords: super F Overriding methods  The Object Class  Modifiers: protected,
This In Java, the keyword this allows an object to refer to itself. Or, in other words, this refers to the current object – the object whose method or.
Slides with material from Alex Mariakakis, Krysta Yousoufian, Mike Ernst, Kellen Donohue Section 3: HW4, ADTs, and more.
Graph Theory Def: A graph is a set of vertices and edges G={V,E} Ex. V = {a,b,c,d,e} E = {ab,bd,ad,ed,ce,cd} Note: above is a purely mathematical definition.
Comp1004: Object Oriented Design I Abstract Classes and Interfaces.
Graphs - II CS 2110, Spring Where did David leave that book? 2.
Section 7: Dijkstra’s Justin Bare and deric Pang
Abstract classes and interfaces
Chapter 13: The Graph Abstract Data Type
JAVA COLLECTIONS LIBRARY
slides borrowed and adapted from Alex Mariakis and CSE 390a
Section 5: HW6 and Interfaces
Section 5: HW6 and Interfaces
Abstract classes and interfaces
Why do Java programmers wear glasses?
What do you call 8 Hobbits?
Interfaces.
Lecture 16 - Interfaces Professor Adams.
Section 7: Dijkstra’s & Midterm Postmortem
OO Design with Inheritance
Section 3 Graphs & Testing
Section 4: Interfaces Parsing Data and
Section 5: HW6 and Interfaces
Section 4: Graphs and Testing
Warmup ["hip","hip"] = Hip Hip Array! ???.
Abstract classes and interfaces
Section 5: HW6 and Interfaces
Chapter 8 Class Inheritance and Interfaces
Presentation transcript:

Slides adapted from Alex Mariakakis, with material from Krysta Yousoufian, Mike Ernst, Kellen Donohue Section 5: HW6 and Interfaces

Agenda Version control and tools review BFS Interfaces Parsing Marvel Data

331 Version control Repository create Working copy update commit check out add check out Working copy for grading

Where is my code? personal computer (/projects/instr/14au/cse331/ YourCSENetID/REPOS/cse 331) attu working copy (/homes/iws/CSENETID/, or other directory) check out commit check out update validate attu scratch copy update (../scratch from attu working copy) repo

Where is my code? Main repo: /projects/instr/etc Not human readable You can’t see files here Personal computer: any directory, via Subclipse or other Working copy: add and edit files here Must check in files for them to go to the repo attu working copy: /homes/iws/CSENETID/ or other Just another working copy, same as personal computer Must svn update to see changes from pc/repo validate copy: attu directory/src/…/scratch NEW WORKING COPY CHECKED OUT FROM REPO May NOT be the same as attu working copy if attu wasn’t updated

Concepts vs tools, 331 vs general Version control: Tools: svn, TortoiseSVN, Subclipse Ant: Concept: build management validate Remote access: Tools: ssh, PuTTY, WinSCP Javadocs: concept tool 331 general concept

Graphs A B CD E Can I reach B from A?

Breadth-First Search (BFS) Often used for discovering connectivity Calculates the shortest path if and only if all edges have same positive or no weight Depth-first search (DFS) is commonly mentioned with BFS BFS looks “wide”, DFS looks “deep” Can also be used for discovery, but not the shortest path

BFS Pseudocode public boolean find(Node start, Node end) { put start node in a queue while (queue is not empty) { pop node N off queue if (N is goal) return true; else { for each node O that is child of N push O onto queue } return false; }

Breadth-First Search Q: <> Q: Q: <> Q: DONE A BC

Breadth-First Search with Cycle Q: <> Q: Q: <> Q: Q: <> Q: Q: <> Q: NEVER DONE A BC

BFS Pseudocode public boolean find(Node start, Node end) { put start node in a queue while (queue is not empty) { pop node N off queue if (N is goal) return true; else { for each node O that is child of N push O onto queue } return false; } What if there’s a cycle? What if there’s no path between start and end? Mark the node as visited!

Breadth-First Search Q: <> A B CD E

Breadth-First Search Q: <> Q: A B CD E

Breadth-First Search Q: <> Q: Q: <> A E B DC

Breadth-First Search Q: <> Q: Q: <> Q: A C E B D

Breadth-First Search Q: <> Q: Q: <> Q: A CD E B

Breadth-First Search Q: <> Q: Q: <> Q: A CD B E

Breadth-First Search Q: <> Q: Q: <> Q: A CD E B

Breadth-First Search Q: <> Q: Q: <> Q: A CD E B

Breadth-First Search Q: <> Q: Q: <> Q: DONE A CD E B

Shortest Paths with BFS DestinationPathCost A 1 B 0 C 2 D 1 E 2 From Node B A B CD E

Shortest Paths with Weights A B CD E DestinationPathCost A 2 B 0 C 5 D 7 E 7 From Node B Paths are not the same!

Classes, Interfaces, and Types The fundamental unit of programming in Java is a class Classes can extend other classes and implement interfaces Interfaces can extend other interfaces

Classes, Objects, and Java Everything is an instance of a class Defines data and methods Every class extends exactly one other class Object if no explicit superclass Inherits superclass fields Every class also defines a type Foo defines type Foo Foo inherits all inherited types Java classes contain both specification and implementation!

Interfaces Pure type declaration public interface Comparable { int compareTo(Object other); } Can contain: Method specifications (implicitly public abstract ) Named constants (implicitly public final static ) Does not contain implementation Cannot create instances of interfaces

Implementing Interfaces A class can implement one or more interfaces class Kitten implements Pettable, Huggable The implementing class and its instances have the interface type(s) as well as the class type(s) The class must provide or inherit an implementation of all methods defined by the interface(s) Not true for abstract classes

Using Interface Types An interface defines a type, so we can declare variables and parameters of that type A variable with an interface type can refer to an object of any class implementing that type List x = new ArrayList (); void sort(List myList) {…}

Guidelines for Interfaces Provide interfaces for significant types and abstractions Write code using interface types like Map instead of HashMap and TreeMap wherever possible Allows code to work with different implementations later on Both interfaces and classes are appropriate in various circumstances

Demo Parsing the Marvel data