📄 manager.java~1~
字号:
package empress;
/**
* <p>Title:Empresses </p>
*
* <p>Description:Empresses Show Software </p>
*
* <p>Copyright: Copyright (c) 2004</p>
*
* <p>Company:Bluebell </p>
*
* @authorJamy not attributable
* @version 1.0
*/
public class Manager {
Maps mps;
Empresses e[];
int empressNumber;
int current = 0;
int i = 0;
boolean first = true;
MapPage mp;
Hasilica has;
String s;
public Manager(int empressNumber)
{
has = new Hasilica(empressNumber);
mps = new Maps(empressNumber);
mp = new MapPage(empressNumber);
e = new Empresses[empressNumber]; //Constructor to prepare for the resource
for(int i = 0 ; i < empressNumber; i++) //that would be used
{
e[i] = new Empresses(i,mp,has,empressNumber);//Initionalize the Empresses and number them
}
this.empressNumber = empressNumber;
}
public void arrangement()
{
while(first)//fist is the sign to tell wether the program hava to exit
{
i = current;//record the cuurent Empress
thisWay(e[current]);
if(mp.mapPage[1][empressNumber-1] >= 0)//if find a solution
{
mps.record(mp);//record the solution
Hasilica has = new Hasilica(empressNumber);//generate a map to show the position
has.showMapOfEmpresses(mp); //of the eight Empresses
mp.mapPage[1][empressNumber-1] = -1; //to sign the map be invalid
}
}
has.setVisible(false); //to hide the last map which is not the solution
has = null; //free the space
}
public void thisWay(Empresses e)
{
if(e.adjust())//if the current Empress could find the position
{
if(current < (empressNumber - 1))
{
current = i + 1;//go on find the position of "i+1"'th Empress
}
else
{
current = empressNumber - 1;
}
}
else
{
e.y = -1;//to set the current Empress out of the map
if(current > 0)
{
current = i -1;//next Empress is "i-1"'th Empress
}
else
{
current = 0;
first = false;
}
}
}
public void reportToEmperor()
{
mps.showRecords();
System.out.println("**************************************"+mps.getLength());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -