Page 1 – Spring 2010Steffen Vissing Andersen Software Development with UML and Java 2 SDJ I2, Spring 2010 Agenda – week 7, 2010 • Pakages • Looking back.

Slides:



Advertisements
Similar presentations
Chapter 25 Lists, Stacks, Queues, and Priority Queues
Advertisements

CS Data Structures I Chapter 6 Stacks I 2 Topics ADT Stack Stack Operations Using ADT Stack Line editor Bracket checking Special-Palindromes Implementation.
Advanced Piloting Cruise Plot.
Chapter 1 The Study of Body Function Image PowerPoint
1 Copyright © 2013 Elsevier Inc. All rights reserved. Appendix 01.
1 Copyright © 2010, Elsevier Inc. All rights Reserved Fig 2.1 Chapter 2.
Business Transaction Management Software for Application Coordination 1 Business Processes and Coordination.
1 Introduction to Computation and Problem Solving Class 23: Introduction to Data Structures: Stacks and Queues Prof. Steven R. Lerman and Dr. V. Judson.
Introduction to Computation and Problem
© 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 11: Structure and Union Types Problem Solving & Program Design.
11 Copyright © 2005, Oracle. All rights reserved. Using Arrays and Collections.
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Title Subtitle.
My Alphabet Book abcdefghijklm nopqrstuvwxyz.
DIVIDING INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
FACTORING ax2 + bx + c Think “unfoil” Work down, Show all steps.
Addition Facts
Year 6 mental test 10 second questions
2010 fotografiert von Jürgen Roßberg © Fr 1 Sa 2 So 3 Mo 4 Di 5 Mi 6 Do 7 Fr 8 Sa 9 So 10 Mo 11 Di 12 Mi 13 Do 14 Fr 15 Sa 16 So 17 Mo 18 Di 19.
ZMQS ZMQS
REVIEW: Arthropod ID. 1. Name the subphylum. 2. Name the subphylum. 3. Name the order.
Topic 12 The List ADT. 9-2 Objectives Examine list processing and various ordering techniques Define a list abstract data type Examine various list implementations.
Linked List A linked list consists of a number of links, each of which has a reference to the next link. Adding and removing elements in the middle of.
Linked Lists Chapter 4.
Data Structures ADT List
Chapter 24 Lists, Stacks, and Queues
ITEC200 Week04 Lists and the Collection Interface.
1 CSE1301 Computer Programming: Lecture 27 List Manipulation.
1 CompSci 105 SS 2005 Principles of Computer Science Lecture 11: Linked Lists Lecturer: Santokh Singh Assignment 2 due tomorrow, i.e. Friday 21 Jan 2005.
Data Structures Part 2 Stacks, Queues, Trees, and Graphs Briana B. Morrison CSE 1302C Spring 2010.
Double-Linked Lists and Circular Lists
John Hurley Cal State LA
ABC Technology Project
1 Undirected Breadth First Search F A BCG DE H 2 F A BCG DE H Queue: A get Undiscovered Fringe Finished Active 0 distance from A visit(A)
VOORBLAD.
15. Oktober Oktober Oktober 2012.
Review Pseudo Code Basic elements of Pseudo code
1 Breadth First Search s s Undiscovered Discovered Finished Queue: s Top of queue 2 1 Shortest path from s.
1 public class Newton { public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t)
The List ADT Textbook Sections
Object-Oriented Programming. 2 An object, similar to a real-world object, is an entity with certain properties, and with the ability to react in certain.
BIOLOGY AUGUST 2013 OPENING ASSIGNMENTS. AUGUST 7, 2013  Question goes here!
Factor P 16 8(8-5ab) 4(d² + 4) 3rs(2r – s) 15cd(1 + 2cd) 8(4a² + 3b²)
Squares and Square Root WALK. Solve each problem REVIEW:
Basel-ICU-Journal Challenge18/20/ Basel-ICU-Journal Challenge8/20/2014.
1..
© 2012 National Heart Foundation of Australia. Slide 2.
Copyright © 2013 by John Wiley & Sons. All rights reserved. HOW TO CREATE LINKED LISTS FROM SCRATCH CHAPTER Slides by Rick Giles 16 Only Linked List Part.
Understanding Generalist Practice, 5e, Kirst-Ashman/Hull
GG Consulting, LLC I-SUITE. Source: TEA SHARS Frequently asked questions 2.
Addition 1’s to 20.
25 seconds left…...
Januar MDMDFSSMDMDFSSS
Week 1.
Analyzing Genes and Genomes
We will resume in: 25 Minutes.
©Brooks/Cole, 2001 Chapter 12 Derived Types-- Enumerated, Structure and Union.
Essential Cell Biology
Intracellular Compartments and Transport
PSSA Preparation.
Essential Cell Biology
Immunobiology: The Immune System in Health & Disease Sixth Edition
CpSc 3220 Designing a Database
Page 1 – Spring 2010Steffen Vissing Andersen Software Development with UML and Java 2 SDJ I2, Spring 2010 Agenda – Week 8 Linked List (a reference based.
Presentation transcript:

Page 1 – Spring 2010Steffen Vissing Andersen Software Development with UML and Java 2 SDJ I2, Spring 2010 Agenda – week 7, 2010 • Pakages • Looking back • Looking forward • Packages • Interfaces

Page 2 – Spring 2010Steffen Vissing Andersen Download, Install/Setup 1.Java SE SDK ( 2.Java SE SDK - Documentation 3.Setup Environment Variables (e.g. in Windows) 4.Eclipse IDE ( 5.JUDE UML ( • All the above is on the USB stick • Video – How To Install: (

Page 3 – Spring 2010Steffen Vissing Andersen Looking back: Java Packages

Page 4 – Spring 2010Steffen Vissing Andersen Java Packages

Page 5 – Spring 2010Steffen Vissing Andersen Package dependencies (class level)

Page 6 – Spring 2010Steffen Vissing Andersen Package dependencies (package level)

Page 7 – Spring 2010Steffen Vissing Andersen Looking forward: What to implement in this course • We will create a lot of collection classes during this course • List containing Strings • array based • dynamic linked based • List with generic type • array based • dynamic linked based • Stack • … • Queue • … • Set • … • SortedSet • …

Page 8 – Spring 2010Steffen Vissing Andersen UML package diagram

Page 9 – Spring 2010Steffen Vissing Andersen Package stringcollection

Page 10 – Spring 2010Steffen Vissing Andersen Package stringcollection (StringList)

Page 11 – Spring 2010Steffen Vissing Andersen Interface IStringList (realization line)

Page 12 – Spring 2010Steffen Vissing Andersen IStringList

Page 13 – Spring 2010Steffen Vissing Andersen Interface for a List of Strings package collection.stringcollection; public interface IStringList { public void add(int index, String element); public void add(String element); public void clear(); public boolean contains(String element); public String get(int index); public int indexOf(String element); public boolean isEmpty(); public void remove(int index); public void remove(String element); public void set(int index, String element); public int size(); }

Page 14 – Spring 2010Steffen Vissing Andersen Documentation for IStringList (1/8)

Page 15 – Spring 2010Steffen Vissing Andersen Documentation for IStringList (2/8)

Page 16 – Spring 2010Steffen Vissing Andersen Documentation for IStringList (3/8)

Page 17 – Spring 2010Steffen Vissing Andersen Documentation for IStringList (4/8)

Page 18 – Spring 2010Steffen Vissing Andersen Documentation for IStringList (5/8)

Page 19 – Spring 2010Steffen Vissing Andersen Documentation for IStringList (6/8)

Page 20 – Spring 2010Steffen Vissing Andersen Documentation for IStringList (7/8)

Page 21 – Spring 2010Steffen Vissing Andersen Documentation for IStringList (8/8)

Page 22 – Spring 2010Steffen Vissing Andersen UML package diagram (StringListArrayBased)

Page 23 – Spring 2010Steffen Vissing Andersen StringListArrayBased  Example 1: Calling method add(String element) on a StringListArrayBased-object with the parameter element="G" will  Add the element "G" to collection[6]  Increment size by one  Example 2: Alternatively, calling add(int index, String element) with the parameters index=3 and element="G" will  Move "F" to index 6, "E" to index 5 and "D" to index 4  Add the element "G" to index 3 (i.e. collection[3] )  Increment size by one

Page 24 – Spring 2010Steffen Vissing Andersen class StringListArrayBased package collection.stringcollection; public class StringListArrayBased implements IStringList { private String[] collection; private int size; private static final int DEFAULT_CAPACITY = 20; public StringListArrayBased(int capacity) { //TODO – implement the constructor } public StringListArrayBased() { //TODO – implement the constructor }... // TODO - implement all methods (including method toString()) }

Page 25 – Spring 2010Steffen Vissing Andersen A little help…... public void add(int index, String element) { if (index > size || index < 0) throw new IndexOutOfBoundsException("index=" + index + " size=" + size); if (size >= collection.length) throw new IllegalStateException(); shiftUp(index); // Make room for the element (has to be implemented) collection[index] = element; size++; }...

Page 26 – Spring 2010Steffen Vissing Andersen Exercises • Implement the interface IStringList – using an array to store the elements (call the class: StringListArrayBased in package collection.stringcollection ) • Find documentation in the SDJI2  javadoc  IStringList, or here: •

Page 27 – Spring 2010Steffen Vissing Andersen StringListTest (1/4) import collection.stringcollection.IStringList; public class StringListTest { public static void main(String[] args) { IStringList list = new StringListArrayBased(); list.add("Bob"); list.add("Dee"); printList("BD: ", list); list.add(1,"Carl"); // add in the middle printList("BCD: ", list); list.add(0,"Allan"); // add first printList("ABCD: ", list); list.add(4,"Eric"); // add last printList("ABCDE: ", list);

Page 28 – Spring 2010Steffen Vissing Andersen StringListTest (2/4) printListBackwards("EDCBA: ", list); list.remove(0); // remove first printList("BCDE: ", list); list.remove(list.size()-1); // remove last printList("BCD: ", list); list.remove("Carl"); // remove middle printList("BD: ", list); printListBackwards("DB: ", list); }

Page 29 – Spring 2010Steffen Vissing Andersen StringListTest (3/4) private static void printList(String prompt, IStringList list) { System.out.print(prompt + "{"); for (int i=0; i<list.size(); i++) { System.out.print(list.get(i)); if (i < list.size() - 1) System.out.print(", "); } System.out.println("}"); }

Page 30 – Spring 2010Steffen Vissing Andersen StringListTest (4/4) private static void printListBackwards(String prompt, IStringList list) { System.out.print(prompt + "{"); for (int i=list.size()-1; i>=0; i--) { System.out.print(list.get(i)); if (i > 0) System.out.print(", "); } System.out.println("}"); }

Page 31 – Spring 2010Steffen Vissing Andersen StringListTest (output) BD: {Bob, Dee} BCD: {Bob, Carl, Dee} ABCD: {Allan, Bob, Carl, Dee} ABCDE: {Allan, Bob, Carl, Dee, Eric} EDCBA: {Eric, Dee, Carl, Bob, Allan} BCDE: {Bob, Carl, Dee, Eric} BCD: {Bob, Carl, Dee} BD: {Bob, Dee} DB: {Dee, Bob}