-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Contents added and generating buildings with custom contents are added
- Loading branch information
DDred
committed
Mar 24, 2011
1 parent
dbb5082
commit 38d13a4
Showing
7 changed files
with
154 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/libiada/IntervalAnalysis/Buildings/BuildingsGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package libiada.IntervalAnalysis.Buildings; | ||
|
||
import libiada.IntervalAnalysis.Chain; | ||
|
||
import java.util.ArrayList; | ||
|
||
/** | ||
* Created by IntelliJ IDEA. | ||
* User: Alex | ||
* Date: 25.03.11 | ||
* Time: 2:41 | ||
*/ | ||
public class BuildingsGenerator { | ||
public ArrayList<String> GetBuildings(int chainLength, int alphabetPower) { | ||
Tree tree = new Tree(); | ||
tree.rebuildTreeForBuildings(chainLength, alphabetPower); | ||
return tree.getBuildingsAsStrings(); | ||
} | ||
|
||
public ArrayList<String> GetBuildings(Contents contents) throws Exception { | ||
Tree tree = new Tree(); | ||
tree.rebuildTreeForBuildings(contents); | ||
return tree.getBuildingsAsStrings(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package libiada.IntervalAnalysis.Buildings; | ||
|
||
import libiada.Root.IBaseObject; | ||
import libiada.TheoryOfSet.Alphabet; | ||
|
||
import java.util.ArrayList; | ||
|
||
/** | ||
* Created by IntelliJ IDEA. | ||
* User: Alex | ||
* Date: 25.03.11 | ||
* Time: 2:50 | ||
*/ | ||
public class Contents { | ||
public Alphabet alphabet = new Alphabet(); | ||
public ArrayList<Integer> counts = new ArrayList<Integer>(); | ||
|
||
public void add(IBaseObject obj, int count) throws Exception { | ||
if (!alphabet.isContains(obj)) { | ||
alphabet.add(obj); | ||
counts.add(count); | ||
} | ||
else { | ||
int index = alphabet.indexOf(obj); | ||
counts.set(index, counts.get(index) + count); | ||
} | ||
} | ||
|
||
public void subElementCount(int index) throws Exception { | ||
if (counts.size() < index) { | ||
throw new Exception("Элемент с таким индексом отсутствует в составе"); | ||
} | ||
counts.set(index - 1, counts.get(index - 1) - 1); | ||
} | ||
|
||
public int getElementCount(int index) throws Exception { | ||
if (counts.size() < index) { | ||
throw new Exception("Элемент с таким индексом отсутствует в составе"); | ||
} | ||
return counts.get(index - 1); | ||
} | ||
|
||
public int getChainLength() { | ||
int len = 0; | ||
for (Integer count : counts) { | ||
len += count; | ||
} | ||
return len; | ||
} | ||
|
||
@Override | ||
public Contents clone() { | ||
Contents contents = new Contents(); | ||
for (int index = 0; index < counts.size(); index++) { | ||
try { | ||
contents.add(alphabet.get(index), counts.get(index)); | ||
} catch (Exception e) { | ||
System.err.print("Ошибка клонирпования состава"); | ||
} | ||
} | ||
return contents; | ||
} | ||
|
||
public int getPower() { | ||
return alphabet.getPower(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters