package buffalo.twoTasksAnalysis;
import buffalo.dataStructures.*;
import buffalo.twoTasksAnalysis.TwoTasksCircuit;
/**
Cette classe permet lorsqu'on a identifier les quatre <CODE>Operations</CODE>
caractéristiques d'un circuit dans lequel deux <CODE>Taches</CODE>
(et seulement deux) sont impliquées, de les mettre en ordre et de
les passer toutes les quatre encapsulées dans le même objet.
*/
public class TwoTasksCircuit
{
/*
Quatre opérations du circuit à deux <CODE>Taches</CODE>,
déignées comme des points cardinaux.
*/
private Operation northEast;
private Operation northWest;
private Operation southEast;
private Operation southWest;
/**
Le constructeur prend en paramètre le northBuffer et les
quatre <CODE>Operations</CODE> impliquées dans le
circuit; on peut passer ces quatre <CODE>Operations</CODE>
dans n'importe quel ordre.
*/
public TwoTasksCircuit(Task northTask, Operation operation1, Operation operation2,
Operation operation3, Operation operation4)
{
Operation firstNorthOperation = null;
Operation secondNorthOperation = null;
Operation firstSouthOperation = null;
Operation secondSouthOperation = null;
if(operation1.getActiveTask() == northTask)
{
firstNorthOperation = operation1;
}
else
{
firstSouthOperation = operation1;
}
if (operation2.getActiveTask() == northTask)
{
if (firstNorthOperation == null)
{
firstNorthOperation = operation2;
}
else
{
secondNorthOperation = operation2;
}
}
else
{
if (firstSouthOperation == null)
{
firstSouthOperation = operation2;
}
else
{
secondSouthOperation = operation2;
}
}
if (operation3.getActiveTask() == northTask)
{
if (firstNorthOperation == null)
{
firstNorthOperation = operation3;
}
else
{
secondNorthOperation = operation3;
}
}
else
{
if (firstSouthOperation == null)
{
firstSouthOperation = operation3;
}
else
{
secondSouthOperation = operation3;
}
}
if(operation4.getActiveTask() == northTask)
{
secondNorthOperation = operation4;
}
else
{
secondSouthOperation = operation4;
}
if (firstNorthOperation.getIndex() <
secondNorthOperation.getIndex())
{
this.northWest = firstNorthOperation;
this.northEast = secondNorthOperation;
}
else
{
this.northWest = secondNorthOperation;
this.northEast = firstNorthOperation;
}
if (firstSouthOperation.getIndex() <
secondSouthOperation.getIndex())
{
this.southWest = firstSouthOperation;
this.southEast = secondSouthOperation;
}
else
{
this.southWest = secondSouthOperation;
this.southEast = firstSouthOperation;
}
}
/*----------------------------------------------------------*/
/*Accesseurs*/
/**
Retourne l'<CODE>Operation</CODE> en haut à droite
*/
public Operation getNorthEast()
{
return this.northEast;
}
/*----------------------------------------------------------*/
/**
Retourne l'<CODE>Operation</CODE> en haut à gauche
*/
public Operation getNorthWest()
{
return this.northWest;
}
/*----------------------------------------------------------*/
/**
Retourne l'<CODE>Operation</CODE> en bas à droite
*/
public Operation getSouthEast()
{
return this.southEast;
}
/*----------------------------------------------------------*/
/**
Retourne l'<CODE>Operation</CODE> en bas à gauche
*/
public Operation getSouthWest()
{
return this.northWest;
}
/*----------------------------------------------------------*/
/**
Retourne le circuit au format chaîne de caractères.
*/
public String toString()
{
String result = "{";
result += " northTask = " + northEast.getActiveTask().getIndex();
result += " ; southTask = " + southEast.getActiveTask().getIndex();
result += " ; northWest = " + northWest.getIndex();
result += " ; northEast = " + northEast.getIndex();
result += " ; southWest = " + southWest.getIndex();
result += " ; southEast = " + southEast.getIndex() + " } ";
return result;
}
}