Software Development with UML and Java 2 SDJ I2, Spring 2010

Similar documents
Masters programmes in Computer Science and Information Systems. Object-Oriented Design and Programming. Sample module entry test xxth December 2013

CMSC 202H. ArrayList, Multidimensional Arrays

1.00 Lecture 35. Data Structures: Introduction Stacks, Queues. Reading for next time: Big Java: Data Structures

J a v a Quiz (Unit 3, Test 0 Practice)

Preet raj Core Java and Databases CS4PR. Time Allotted: 3 Hours. Final Exam: Total Possible Points 75

CS170 Lab 11 Abstract Data Types & Objects

Class 32: The Java Collections Framework

Generic Types in Java. Example. Another Example. Type Casting. An Aside: Autoboxing 4/16/2013 GENERIC TYPES AND THE JAVA COLLECTIONS FRAMEWORK.

The Java Collections Framework

Collections in Java. Arrays. Iterators. Collections (also called containers) Has special language support. Iterator (i) Collection (i) Set (i),

Introduction to Java

JAVA ARRAY EXAMPLE PDF

Introduction to Object-Oriented Programming

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program

Assignment 3 Version 2.0 Reactive NoSQL Due April 13

Sample CSE8A midterm Multiple Choice (circle one)

Web Services using Tomcat and Eclipse

Contents. 9-1 Copyright (c) N. Afshartous

You are to simulate the process by making a record of the balls chosen, in the sequence in which they are chosen. Typical output for a run would be:

JUnit Automated Software Testing Framework. Jeff Offutt. SWE 437 George Mason University Thanks in part to Aynur Abdurazik. What is JUnit?

HW3: Programming with stacks

Data Structures and Algorithms

An Overview of Java. overview-1

Yosemite National Park, California. CSE 114 Computer Science I Inheritance

Part I. Multiple Choice Questions (2 points each):

Chulalongkorn University International School of Engineering Department of Computer Engineering Computer Programming Lab.

CompSci-61B, Data Structures Final Exam

COSC Introduction to Computer Science I Section A, Summer Question Out of Mark A Total 16. B-1 7 B-2 4 B-3 4 B-4 4 B Total 19

Consuming a Web Service(SOAP and RESTful) in Java. Cheat Sheet For Consuming Services in Java

1.00 Lecture 1. Course information Course staff (TA, instructor names on syllabus/faq): 2 instructors, 4 TAs, 2 Lab TAs, graders

Lecture J - Exceptions

Installing Java (Windows) and Writing your First Program

Project 4 DB A Simple database program

Chapter 2 Introduction to Java programming

Tutorial on OpenCV for Android Setup

Massachusetts Institute of Technology 6.005: Elements of Software Construction Fall 2011 Quiz 1 October 14, Instructions

How to use the Eclipse IDE for Java Application Development

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013

Java Program Coding Standards Programming for Information Technology

CmpSci 187: Programming with Data Structures Spring 2015

First Java Programs. V. Paúl Pauca. CSC 111D Fall, Department of Computer Science Wake Forest University. Introduction to Computer Science

Unit Testing & JUnit

Collections.sort(population); // Método de ordenamiento

2009 Tutorial (DB4O and Visual Studio 2008 Express)

JDK 1.5 Updates for Introduction to Java Programming with SUN ONE Studio 4

Classes and Objects in Java Constructors. In creating objects of the type Fraction, we have used statements similar to the following:

Amazon Glacier. Developer Guide API Version

Data Structures in the Java API

AP Computer Science Java Subset

Application Development with TCP/IP. Brian S. Mitchell Drexel University

Unit Testing and JUnit

Licensed for viewing only. Printing is prohibited. For hard copies, please purchase from

5.2 Q2 The control variable of a counter-controlled loop should be declared as: a.int. b.float. c.double. d.any of the above. ANS: a. int.

D06 PROGRAMMING with JAVA

CSE 1223: Introduction to Computer Programming in Java Chapter 7 File I/O

Overview of Web Services API

ID TECH UniMag Android SDK User Manual

WRITING DATA TO A BINARY FILE

A TOOL FOR DATA STRUCTURE VISUALIZATION AND USER-DEFINED ALGORITHM ANIMATION

Outline. Computer Science 331. Stack ADT. Definition of a Stack ADT. Stacks. Parenthesis Matching. Mike Jacobson

Advanced Java Client API

CSE 1020 Introduction to Computer Science I A sample nal exam

Tools for Integration Testing

CSE 8B Midterm Fall 2015

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

Visualising Java Data Structures as Graphs

Using Two-Dimensional Arrays

COSC 111: Computer Programming I. Dr. Bowen Hui University of Bri>sh Columbia Okanagan

Arrays. Atul Prakash Readings: Chapter 10, Downey Sun s Java tutorial on Arrays:

Creating a Simple, Multithreaded Chat System with Java

1) Which of the following is a constant, according to Java naming conventions? a. PI b. Test c. x d. radius

Building Java Programs

Topic 11 Scanner object, conditional execution

Java CPD (I) Frans Coenen Department of Computer Science

Install Java Development Kit (JDK) 1.8

Handout 3 cs180 - Programming Fundamentals Spring 15 Page 1 of 6. Handout 3. Strings and String Class. Input/Output with JOptionPane.

Working with Java Collections

Building Java Programs

Files and input/output streams

Object-Oriented Programming in Java

The following program is aiming to extract from a simple text file an analysis of the content such as:

Table of Contents. LESSON: The JUnit Test Tool...1. Subjects...2. Testing What JUnit Provides...4. JUnit Concepts...5

Translating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language

JDBC. It is connected by the Native Module of dependent form of h/w like.dll or.so. ex) OCI driver for local connection to Oracle

LAB4 Making Classes and Objects

Stacks. Data Structures and Data Types. Collections

Last not not Last Last Next! Next! Line Line Forms Forms Here Here Last In, First Out Last In, First Out not Last Next! Call stack: Worst line ever!

Java with Eclipse: Setup & Getting Started

Transcription:

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

Download, Install/Setup 1. Java SE SDK (http://java.sun.com/javase/downloads) 2. Java SE SDK - Documentation 3. Setup Environment Variables (e.g. in Windows) 4. Eclipse IDE (http://www.eclipse.org) 5. JUDE UML (http://jude.change-vision.com/) All the above is on the USB stick Video How To Install: (http://it-engineering.dk/course/a09/sdji1a/tools/_video) Page 2 Spring 2010

Looking back: Java Packages Page 3 Spring 2010

Java Packages Page 4 Spring 2010

Package dependencies (class level) Page 5 Spring 2010

Package dependencies (package level) Page 6 Spring 2010

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 7 Spring 2010

UML package diagram Page 8 Spring 2010

Package stringcollection Page 9 Spring 2010

Package stringcollection (StringList) Page 10 Spring 2010

Interface IStringList (realization line) Page 11 Spring 2010

IStringList Page 12 Spring 2010

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 13 Spring 2010

Documentation for IStringList (1/8) Page 14 Spring 2010

Documentation for IStringList (2/8) Page 15 Spring 2010

Documentation for IStringList (3/8) Page 16 Spring 2010

Documentation for IStringList (4/8) Page 17 Spring 2010

Documentation for IStringList (5/8) Page 18 Spring 2010

Documentation for IStringList (6/8) Page 19 Spring 2010

Documentation for IStringList (7/8) Page 20 Spring 2010

Documentation for IStringList (8/8) Page 21 Spring 2010

UML package diagram (StringListArrayBased) Page 22 Spring 2010

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 23 Spring 2010

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 24 Spring 2010

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 25 Spring 2010

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: http://it-engineering.dk/course/s10/sdji2b/javadoc/istringlist.html Page 26 Spring 2010

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 27 Spring 2010

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 28 Spring 2010

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 29 Spring 2010

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 30 Spring 2010

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} Page 31 Spring 2010