-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSpace.java
74 lines (66 loc) · 2.6 KB
/
Space.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//-----------------------------------------------------------------------------------------------------------------------------------------
package model;
import customexception.InvalidMatricesException;
//-----------------------------------------------------------------------------------------------------------------------------------------
/**
*
* @author Lina Acosta Holguin
* @author Lina Salinas Delgado
* @author Maria Ordoñez Ordoñez
* @author Juan Valencia Jaramillo
* This class manage the necessary attributes and methods to create the space as the part of the battlefield
*/
public class Space {
private Venus venus;
private Mars mars;
//----------------------------------------------------METHODS FOR THIS CLASS---------------------------------------------------------------
/**
* <b>Space Constructor</b>
* This method allows to create the space as an scenerio to deliver the battle
*/
public Space () {
venus = new Venus("Venus");
mars = new Mars("Mars");
}
//-----------------------------------------------------------------------------------------------------------------------------------------
/**
* This method returns the venus associated planet in the space
* @return venus
*/
public Planet getVenus() {
return venus;
}
//-----------------------------------------------------------------------------------------------------------------------------------------
/**
* This method returns the mars associated planet in the space
* @return mars
*/
public Planet getMars() {
return mars;
}
//-----------------------------------------------------------------------------------------------------------------------------------------
/**
* This method calculates the product between the two matrices provided by venus in order to find the enemies spaceship
* in the resultant matrix
* @throws InvalidMatricesException
* @throws NullPointerException
*/
public void generateBattleField(){
int[][] m1 = venus.getLastMatrix();
int[][] m2 = venus.getCoefficientMatrix();
int fil_m1 = m1.length;
int col_m1 = m1[0].length;
int fil_m2 = m2.length;
int col_m2 = m2[0].length;
int[][] current = new int[fil_m1][col_m2];
for (int i=0; i < current.length; i++) {
for(int j = 0; j<current[i].length; j++) {
for (int k=0; k<col_m1; k++) {
current[i][j] += m1[i][k]*m2[k][j];
}
}
}
mars.setSearchedMatrix(current);
}
//-----------------------------------------------------------------------------------------------------------------------------------------
}