OOP2

OEF03.java

1
/*	Copyright 2015 Maarten Vangeneugden
2
3
	Licensed under the Apache License, Version 2.0 (the "License");
4
	you may not use this file except in compliance with the License.
5
	You may obtain a copy of the License at
6
7
		https://www.apache.org/licenses/LICENSE-2.0
8
9
	Unless required by applicable law or agreed to in writing, software
10
	distributed under the License is distributed on an "AS IS" BASIS,
11
	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
	See the License for the specific language governing permissions and
13
	limitations under the License.*/
14
import java.util.*;
15
16
class Matrix
17
{
18
	//No constructor. Java makes a default constructor.
19
	
20
	public int[][] matrix()
21
	{
22
		return m_matrix;
23
	}
24
	public void setMatrix(int[][] matrix)
25
	{
26
		for(int i=0; i<3; i++)
27
			for(int j=0; j<3; j++)
28
				m_matrix[i][j] = matrix[i][j];
29
	}
30
	
31
	public void sum(Matrix matrix)
32
	{
33
		for(int i=0; i<3; i++)
34
			for(int j=0; j<3; j++)
35
				m_matrix[i][j] += matrix.matrix()[i][j];
36
	}
37
	
38
	public void product(Matrix matrix)
39
	{
40
		for(int i=0; i<3; i++)
41
			for(int j=0; j<3; j++)
42
				m_matrix[i][j] *= matrix.matrix()[i][j];
43
	}
44
	
45
	private int m_matrix[][];
46
}
47