Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
MegaWays
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public static class PlateDirection { public const int Vertical = 1; // 直 public const int Horizontal = 2; // 橫 } public class Program { public static void Main(string[] args) { MegaWaysPlateManager manager = new MegaWaysPlateManager(); //test plate List<List<int>> plate = manager.ConvertStringToPlate("18C1,J10,813,5566,4V4588,PTT"); foreach (List<int> column in plate) { foreach (int symbol in column) { Console.Write(symbol+" "); } Console.WriteLine(); } //test award List<int> awardGrids = manager.CheckAward(1, 3, plate); foreach (int grid in awardGrids) { Console.WriteLine(grid); } } } public class MegaWaysPlateManager { private int columnCount = 6; private int symbolWild = 30; private string colorIdMain = "#BFBFBF"; private string colorIdFree = "#D3351C"; // Constructor 設定盤面資料 public MegaWaysPlateManager() { } // 轉換盤面字串成List<List<int>> public List<List<int>> ConvertStringToPlate(string plateStr) { List<List<int>> plate = new List<List<int>>(); string[] tempStrArray = plateStr.Split(','); foreach (string str in tempStrArray) { char[] columnArray = str.ToCharArray(); List<int> tempList = new List<int>(); for( int i = 0 ; i < columnArray.Length; ++i ) { int intValue = (int)columnArray[i]; if (intValue < 58) { intValue = (int)columnArray[i]-48; } else { intValue = (int)columnArray[i]-55; } tempList.Add(intValue); } plate.Add(tempList); } return plate; } // CheckAward // @symbol 中獎符號 // @connect 連線長度 // @plate 盤面 public List<int> CheckAward(int symbol, int connect, List<List<int>> plate) { List<int> award = new List<int>(); int sumCol = 0; for (int i = 0 ; i < connect; ++i) { for (int j = 0 ; j < plate[i].Count; ++j) { if ((plate[i][j] < symbolWild && plate[i][j]%10 == symbol) || plate[i][j] == symbolWild) { award.Add(sumCol+j); } if(j == plate[i].Count-1) { sumCol += plate[i].Count; } } } return award; } // 取得色碼 public string GetColorString(int colorId) { if (colorId == 1 ) { return colorIdMain; } return colorIdFree; } } }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Binary Search Recursive
Hello World!
123.0
Function Tester
iLoveLizzy
Sort String
Trabbd
expression evaluator wich is easy to extend
12 და 14 მარტს დამუშავებული
Group by Example
Please log in to post a comment.