summaryrefslogtreecommitdiff
path: root/sem_5/HLIN505_Java/HLIN505/src/foobar/SUT.java
blob: 7d29953c7b2ba296fe09ff5abc48496dbf9bcf4b (plain)
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
package foobar;

public class SUT {
	private int x;
	private int y;
	private int z;

	public SUT(int x, int y, int z) {
		this.x = x;
		this.y = y;
		this.z = z;
	}
	public SUT(){
		x=1;
		y=3;
		z=5;
	}

	/**
	 * Si t est strictement plus petit que x, on retourne x, sinon si t est strictement plus grand que z, on retourne z, sinon on retourne y.
	 * @param t un entier quelconque
	 * @return x si t<x, z si t>z, y sinon 
	 */
	public int foo(int t){
		int resultat=0;
		if (t<x) resultat=x;
		else if (t>z) resultat=z;
		else resultat=y;
		return resultat;
	}
	
	/**
	 * décale circulairement les valeurs de x, y et z : x prend la valeur de y, y prend la valeur de z et z prend la valeur de x
	 */
	public void bar(){
		int temp=x;
		x=y;
		y=z;
		z=temp;
	}
	
	/**
	 * 
	 */
	public void foobar()throws FooBarException{
		if (x<0) throw new FooBarException();
	}
}