Professional Documents
Culture Documents
Oop Activity For So6 Uml and Arraygroup 6
Oop Activity For So6 Uml and Arraygroup 6
Oop Activity For So6 Uml and Arraygroup 6
Object-Oriented Programming
Links:
Specific Association through which one object applies services of another object.
As a participation in a link, an object may play one of three roles.
• Controller – Operates another object.
• Server – Operated by another object.
• Pray – Both operates and operated by objects
generalization is
Association:
- The identification of association among classes is describing how many classes /
objects are taking part in relationship.
Multiplicity/Cardinality:
- The multiplicity denotes the cardinality of the association. There are three
common kinds of multiplicity across an association.
One – to – One
One – to – Many
Many – to - Many
.
1.5 Materials/Equipment
Computer Unit
1.6 Procedure/s
2. Create the diagrams as describe below and include discussion to each diagram.
a. Use Case diagram, describe how to play chess via an interface able to
connect either different engines or a chess server via internet.
b. Class diagram, describe the pieces, chessboard and the game tree.
c. Object diagram, describe by object snapshots a chess position during a
game.
II. ARRAYS
An ARRAY is like a container that holds a fixed number of values of a particular type.
Memory space is allocated for values of similar type during array declaration. The length
of the array is specified and remains constant at the time it was created.
Example:
int[ ] arrayNumbers;
String[ ] arrayNames;
char[ ] arrayLetters; double[
] arrayDouble;
float[ ]arrayValue;
this indicates that arrayNumbers have a length of 5, meaning the array is capable of
holding or storing 5 integers.
The array index will always start with index of zero [0]. In this case the elements of
arrayNumbers are 10,120,30,80 and 100.
1.5 Materials/Equipment
Computer Unit
1.6 Procedure/s
Output:
Enter 10 integers.
Num 1=10
Num 2=50
Num 3=30
Num 4=80
Num 5=70
Num 6=20
Num 7=90
Num 8=40
Num 9=60
Num 10=100
MyNum[0]=10
MyNum[1]=50
MyNum[2]=30
MyNum[3]=80
MyNum[4]=70
MyNum[5]=20
MyNum[6]=90
MyNum[7]=40
MyNum[8]=60
MyNum[9]=100
Total=550
2. Create a Java program that will store all even numbers to one array (Even[]), then all
odd numbers (Odd[]) to another array.
int
MyNumbers[10]={1,2,3,4,5,6,7,8,9,10}
then display the content or elements of
(1) Array
Source Code:
import java.util.Scanner;
public class LAB3 {
Result:
(2) Array
Source Code:
{ odd[j] =
a[i]; j++;
} else {
even[k] = a[i];
k++;
}
}
System.out.print("Odd[]: ");
if(j > 1) {
for(int i = 0;i < (j-1); i++)
{
System.out.print(odd[i]+ " ");
}
System.out.print(odd[j-1]);
}
System.out.println("");
System.out.print("Even[]: ");
if(k > 1)
{
for(int i = 0; i < (k-1); i++)
{
System.out.print(even[i]+" ");
}
System.out.print(even[k-1]);
}
System.out.println("");
System.out.print("myNumbers[]: "); for(int
z = 0; z<10; z++){ System.out.print(a[z] +
" ");
}
}
}
Result:
1.8 Rating
Criteria Grade