Java Programming Albert Weichselbraun

Agenda • Lecture aims • Schedule and assessment - PC7 accounts and passwords

• Introduction to the program environment (Dia, Eclipse) • Java Collections

JAVA PROGRAMMING

-1-

APRIL 5, 2011

Lecture aims • repetition and verification of the required programming and modeling skills

• introduction of the game framework • software project - requirement specification - project plan - modeling - implementation - deployment and presentation

JAVA PROGRAMMING

-2-

APRIL 5, 2011

Schedule • 8 March 2011: introduction, Java Collections • 15 March 2011: Java GUIs with Swing • 22 March 2011: introduction of the project framework; Java 2D; assessment of the programming topics

• 29 March 2011: test, discussion of the requirement specification • 5 April 2011: completed project plan and modelling • 31 May 2011: presentation of the software project

JAVA PROGRAMMING

-3-

APRIL 5, 2011

Assessment: • participation and work in labs: 20% • test: 25% • software project: 55% - documentation: 20% - implementation: 35%

JAVA PROGRAMMING

-4-

APRIL 5, 2011

Introduction of the Software • Dia • Eclipse - create your first Java project - classes and interfaces - running Java applications - auto completion, refactoring

JAVA PROGRAMMING

-5-

APRIL 5, 2011

Java Collection • lists, sets and maps - different implementations of these types • examples: - lists: ArrayList, Vector - Set: HashSet - Map: HashMap

• used to program aggregation/composition (compare UML diagram)

JAVA PROGRAMMING

-6-

APRIL 5, 2011

1 2

4 5

7 8 9 10 11 12

14 15 16

package simplecollection1; import java.util.*; // Java Collection and Iterator example public class SimpleCollection { public static void main(String[] args) { List testList= new ArrayList(); testList.add("Ta’id Holmes"); testList.add("Vicky Weichsler"); testList.add("Christian Toth"); Collections.sort( testList ); // option 1: compact output Java 5.0 System.out.println("Java 5.0"); for (String name: testList) {

JAVA PROGRAMMING

-7-

APRIL 5, 2011

System.out.println(name);

17 18

}

20

// option 2: indices System.out.println("Indices:"); for (int i=0; i