public void TestMethod()
		{
			DigitGroup dg = new DigitGroup();
			dg.Add(1);
			dg.Add(3);
			dg.Add(1);
			dg.Add(1);
			Assert.AreEqual(9, dg.MinLength, "DigitGroup's property MinLength works wrong");
		}
Exemple #2
0
		public void RebuildDigitGroupCollectionsFromMap() {
			leftCollection = new LeftDigitGroupCollection(Height);
			DigitGroup digitGroup = null;
			int currentBarLength = 0;
			for (int i = 0; i < Height; i++) {
				Cell[] row = map.GetRow(i);
				digitGroup = new DigitGroup();
				for(int j = 0; j < Width; j++) {
					switch(row[j].State) {
						case CellStateEnum.Filled:
							currentBarLength++;
							break;
						case CellStateEnum.Normal:
						case CellStateEnum.Space:
							if(currentBarLength > 0) {
								digitGroup.Add(currentBarLength);
							}
							currentBarLength = 0;
							break;
					}
					if(j == Width - 1 && currentBarLength > 0) {
						digitGroup.Add(currentBarLength);
						currentBarLength = 0;
					}
				}
				leftCollection.Add(digitGroup);
			}
			
			topCollection = new TopDigitGroupCollection(Width);
			currentBarLength = 0;
			for (int i = 0; i < Width; i++) {
				Cell[] column = map.GetColumn(i);
				digitGroup = new DigitGroup();
				for(int j = 0; j < Height; j++) {
					switch(column[j].State) {
						case CellStateEnum.Filled:
							currentBarLength++;
							break;
						case CellStateEnum.Normal:
						case CellStateEnum.Space:
							if(currentBarLength > 0) {
								digitGroup.Add(currentBarLength);
							}
							currentBarLength = 0;
							break;
					}
					if(j == Height - 1 && currentBarLength > 0) {
						digitGroup.Add(currentBarLength);
						currentBarLength = 0;
					}
				}
				topCollection.Add(digitGroup);
			}
		}