Java Fundamental period - Lecture 5

Java : Logic and Operations, control and repetition statements

Summary of the last lecture

How to represent and organize the flow of our program ?

Program execution flow : Activity Diagram

Activity diagrams help developers to represent the succession of tasks necessary to complete the algorithm

Program execution flow : Activity Diagram (2)

Example of an activity diagram usage : first part of the Java project
"Your application should comport a scenario which authenticates a user, and makes him use the Identity management through predefined methods, Create, Update, Delete ..."

Program execution flow : Activity Diagram (3)

Program execution flow : Activity Diagram (4)

Program execution flow: Activity Diagram (5)

Exercise (part of the project) : Realize the authentication of the application

Use what you learnt about the user input/output to realize a login functionality

Repeat operations in Java : the while loop

// while
int size = 10;
int i = 0;
while (i < size) {
 //Some repeated instruction
 i++;
}
	

Repeat operations in Java : the do-while loop

// while
int size = 10;
int i = 0;
do{
 //Some repeated instruction
 i++;
} while (i < size);
	

Repeat operations in Java : the for loop

// for-loop
String[] table = new String[10];
for (int i = 0; i < 10; i++) {
	String current = table[i];
	System.out.println(current);
}

// for-loop, "foreach" way
for (String s : table) {
	System.out.println(s);
}
	

Java data structures: Arrays

Exercise: A factorial implementation

According to the preceding slides, write the factorial computing in 3 different iterating ways
Hint : Remember that the factorial is defined by :
Try to enforce some best practices

Exercise: Completing the project menu

Complete the project application flow according to the activity diagram