public (char letter, int number) GetFieldCoordinates() { var letter = FieldEnum.ToString()[0]; var number = int.Parse(FieldEnum.ToString()[1].ToString()); return(letter, number); }
/// <summary> /// Initializes a new instance of the <see cref="MatchOption" /> class. /// </summary> /// <param name="field">Fields of an email object that can be used to filter results (required).</param> /// <param name="should">How the value of the email field specified should be compared to the value given in the match options. (required).</param> /// <param name="value">The value you wish to compare with the value of the field specified using the `should` value passed. For example `BODY` should `CONTAIN` a value passed. (required).</param> public MatchOption(FieldEnum field = default(FieldEnum), ShouldEnum should = default(ShouldEnum), string value = default(string)) { this.Field = field; this.Should = should; // to ensure "value" is required (not null) this.Value = value ?? throw new ArgumentNullException("value is a required property for MatchOption and cannot be null"); }
// =============================================== Public functions /// <summary>return system Vector 3 field </summary> public Vector3 Get(FieldEnum field) { Vector3 result; switch (field) { //position case FieldEnum.PositionWorld: result = PositionWorld; break; case FieldEnum.PositionLocal: result = positionLocal; break; //first control case FieldEnum.ControlFirstWorld: result = ControlFirstWorld; break; case FieldEnum.ControlFirstLocal: result = controlFirstLocal; break; //second control case FieldEnum.ControlSecondWorld: result = ControlSecondWorld; break; default: result = controlSecondLocal; break; } return(result); }
/// <summary> /// Initializes a new instance of the <see cref="CreateInboxForwarderOptions" /> class. /// </summary> /// <param name="field">Field to match against to trigger inbox forwarding for inbound email (required).</param> /// <param name="match">String or wildcard style match for field specified when evaluating forwarding rules (required).</param> /// <param name="forwardToRecipients">Email addresses to forward an email to if it matches the field and match criteria of the forwarder (required).</param> public CreateInboxForwarderOptions(FieldEnum field = default(FieldEnum), string match = default(string), List <string> forwardToRecipients = default(List <string>)) { this.Field = field; // to ensure "match" is required (not null) this.Match = match ?? throw new ArgumentNullException("match is a required property for CreateInboxForwarderOptions and cannot be null"); // to ensure "forwardToRecipients" is required (not null) this.ForwardToRecipients = forwardToRecipients ?? throw new ArgumentNullException("forwardToRecipients is a required property for CreateInboxForwarderOptions and cannot be null"); }
public static void Main(string[] args) { //laukums, divdimensiju masivs, 3x3 FieldEnum[,] board = GetEmptyBoard(); FieldEnum currentPlayer = FieldEnum.X; bool isGameFinished = false; //drukāsim laukumu Console.WriteLine("Game begins, it's X turn!"); PrintBoard(board); //Katrā cikla iterācijā kāds spēlētājs veic gājienu do { Console.WriteLine(); Console.Write("Please enter row number:"); string row = Console.ReadLine(); Console.Write("Please enter column number:"); string col = Console.ReadLine(); //Ierakstot STOP rindas vai kolonas ievadē, programma/cikls apstājas if (row == "STOP" || col == "STOP") { break; } //Vai ievadītās vērtības nav tukšas. Ja ir, tad kļūda un cikls no jauna if (string.IsNullOrEmpty(row) || string.IsNullOrEmpty(col)) { Console.WriteLine("Please enter non-empty value!"); continue; } //Mēģinām pārveidot ievadītās vērtības par rindas un kolonas skaitļiem int rowNum; int colNum; bool rowSuccess = int.TryParse(row, out rowNum); bool colSuccess = int.TryParse(col, out colNum); //Pārbaudām, vai kādu ievadīto nevarēja pārveidot par skaitli if (!rowSuccess || !colSuccess) { Console.WriteLine("Please enter number type values!"); continue; } //Ievadītās laukuma koordinātas nevar būt ārpus diapazona 1-3 if (rowNum < 1 || rowNum > 3 || colNum < 1 || colNum > 3) { Console.WriteLine("Please enter number values in range 1-3!"); continue; } //Nevar veikt gājienu ne-tukšā lauciņā if (board[rowNum - 1, colNum - 1] != FieldEnum.Empty) { Console.WriteLine("Please make a move in an empty space!"); continue; } board[rowNum - 1, colNum - 1] = currentPlayer; PrintBoard(board); currentPlayer = currentPlayer == FieldEnum.X ? FieldEnum.O : FieldEnum.X; isGameFinished = GameFinished(board); } while (!isGameFinished); }
/// <summary> /// Getting simple predicate /// </summary> /// <param name="field">Predicate entity field</param> /// <param name="fieldValue">Predicate field value</param> /// <param name="operation">Predicate operation</param> /// <returns>Predicate</returns> public virtual Expression <Func <T, bool> > GetPredicate(FieldEnum field, object fieldValue, OperationEnum operation) { var parameter = Expression.Parameter(typeof(T), "x"); var property = Expression.Property(parameter, field.ToString()); var constantValue = GetConstantValue(fieldValue, property, operation); var expression = GetOperationExpression(operation, property, constantValue); var lambda = Expression.Lambda <Func <T, bool> >(expression, parameter); return(lambda); }
/// <summary> /// Initializes a new instance of the <see cref="InboxForwarderDto" /> class. /// </summary> /// <param name="id">id (required).</param> /// <param name="inboxId">inboxId (required).</param> /// <param name="field">field (required).</param> /// <param name="match">match (required).</param> /// <param name="forwardToRecipients">forwardToRecipients (required).</param> /// <param name="createdAt">createdAt (required).</param> public InboxForwarderDto(Guid id = default(Guid), Guid inboxId = default(Guid), FieldEnum field = default(FieldEnum), string match = default(string), List <string> forwardToRecipients = default(List <string>), DateTime createdAt = default(DateTime)) { this.Id = id; this.InboxId = inboxId; this.Field = field; // to ensure "match" is required (not null) this.Match = match ?? throw new ArgumentNullException("match is a required property for InboxForwarderDto and cannot be null"); // to ensure "forwardToRecipients" is required (not null) this.ForwardToRecipients = forwardToRecipients ?? throw new ArgumentNullException("forwardToRecipients is a required property for InboxForwarderDto and cannot be null"); this.CreatedAt = createdAt; }
/// <summary> /// Getting null-predicate /// </summary> /// <param name="field">Predicate field</param> /// <param name="fieldType">Predicate field type</param> /// <returns>Null-predicate</returns> public virtual Expression <Func <T, bool> > GetNullPredicate(FieldEnum field, Type fieldType) { var parameter = Expression.Parameter(typeof(T), "x"); var property = Expression.Property(parameter, field.ToString()); var constantValue = Expression.Constant(null, fieldType); var expression = Expression.Equal(property, constantValue); var lambda = Expression.Lambda <Func <T, bool> >(expression, parameter); return(lambda); }
private static FieldEnum[,] GetEmptyBoard() { FieldEnum[,] board = new FieldEnum[3, 3]; for (int i = 0; i < board.GetLength(0); i++) { for (int j = 0; j < board.GetLength(1); j++) { board[i, j] = FieldEnum.Empty; } } return(board); }
static void Main(string[] args) { FieldEnum[,] board = new FieldEnum[3, 3]; FieldEnum currentSymbol = FieldEnum.X; bool gameResult = false; do { Console.WriteLine($"Enter field - {currentSymbol} - (R,C): "); var userInput = Console.ReadLine(); int row = 0; int col = 0; if (!string.IsNullOrEmpty(userInput) && userInput.Length == 3) { var rowResult = int.TryParse(userInput[0].ToString(), out row); var colResult = int.TryParse(userInput[2].ToString(), out col); if (!rowResult || !colResult) { Console.WriteLine("Invalid input!"); continue; } if (board[row, col] != FieldEnum.Empty) { Console.WriteLine("Field occupied!"); continue; } board[row, col] = currentSymbol; currentSymbol = currentSymbol == FieldEnum.X ? FieldEnum.O : FieldEnum.X; //if (currentSymbol == FieldEnum.X) //{ // currentSymbol = FieldEnum.O; //} //else //{ // currentSymbol = FieldEnum.X; //} //check if game is finished?! - jaunā metodē gameResult = GameOver(board); } } while (!gameResult); currentSymbol = currentSymbol == FieldEnum.X ? FieldEnum.O : FieldEnum.X; Console.WriteLine($"Congratulations {currentSymbol}! You won!"); }
private IEnumerable <Book> FindBooksByTag(FieldEnum field, string value) { foreach (var book in this.books) { if ((field == FieldEnum.ISBN && book.ISBN == value) || (field == FieldEnum.Author && book.Author == value) || (field == FieldEnum.Name && book.Name == value) || (field == FieldEnum.Publisher && book.Publisher == value) || (field == FieldEnum.Year && book.Year == short.Parse(value)) || (field == FieldEnum.Pages && book.Pages == short.Parse(value)) || (field == FieldEnum.Price && book.Price == decimal.Parse(value))) { yield return(book); } } }
protected EdtLabelInfo getTableFieldLabel(BaseField tableField, EdtLabelInfo labelInfo) { if (String.IsNullOrEmpty(labelInfo.Label) == true && String.IsNullOrEmpty(tableField.Label) == false) { // find the label here labelInfo.Label = tableField.Label; } if (String.IsNullOrEmpty(labelInfo.HelpLabel) == true && String.IsNullOrEmpty(tableField.HelpText) == false) { // find the help label here labelInfo.HelpLabel = tableField.HelpText; } if (labelInfo.RequiresDigging() && String.IsNullOrEmpty(tableField.ExtendedDataType) == false) { AxEdt axEdt = Common.CommonUtil.GetModelSaveService().GetExtendedDataType(tableField.ExtendedDataType); labelInfo = this.getEdtBaseLabel(axEdt, labelInfo); } if (labelInfo.RequiresDigging() && tableField is FieldEnum) { FieldEnum tableFieldEnum = tableField as FieldEnum; var axEnum = Common.CommonUtil.GetModelSaveService().GetEnum(tableFieldEnum.EnumType); if (axEnum != null) { if (String.IsNullOrEmpty(labelInfo.Label) == true && String.IsNullOrEmpty(axEnum.Label) == false) { // find the label here labelInfo.Label = axEnum.Label; } if (String.IsNullOrEmpty(labelInfo.HelpLabel) == true && String.IsNullOrEmpty(axEnum.HelpText) == false) { // find the help label here labelInfo.HelpLabel = axEnum.HelpText; } } } return(labelInfo); }
/// <inheritdoc /> /// <summary> /// Get sample frame predicate /// </summary> /// <param name="field">Predicate entity field</param> /// <param name="fieldValue">Predicate field value</param> /// <param name="operation">Predicate operation</param> /// <returns>Predicate</returns> public override Expression <Func <EnterpriseGroup, bool> > GetPredicate( FieldEnum field, object fieldValue, OperationEnum operation) { switch (field) { case FieldEnum.UnitType: return(GetUnitTypePredicate(operation, fieldValue)); case FieldEnum.Region: case FieldEnum.MainActivity: return(False()); default: return(base.GetPredicate(field, fieldValue, operation)); } }
/// <inheritdoc /> /// <summary> /// Get sample frame predicate /// </summary> /// <param name="field">Predicate entity field</param> /// <param name="fieldValue">Predicate field value</param> /// <param name="operation">Predicate operation</param> /// <returns>Predicate</returns> public override Expression <Func <StatisticalUnit, bool> > GetPredicate( FieldEnum field, object fieldValue, OperationEnum operation) { switch (field) { case FieldEnum.UnitType: return(GetUnitTypePredicate(operation, fieldValue)); case FieldEnum.Region: return(GetRegionPredicate(fieldValue, operation)); case FieldEnum.MainActivity: return(GetActivityPredicate(fieldValue, operation)); default: return(base.GetPredicate(field, fieldValue, operation)); } }
/// <inheritdoc /> /// <summary> /// Get sample frame predicate /// </summary> /// <param name="field">Predicate entity field</param> /// <param name="fieldValue">Predicate field value</param> /// <param name="operation">Predicate operation</param> /// <returns>Predicate</returns> public override Expression <Func <T, bool> > GetPredicate( FieldEnum field, object fieldValue, OperationEnum operation) { var isStatUnit = typeof(T) == typeof(StatisticalUnit); switch (field) { case FieldEnum.UnitType: return(GetUnitTypePredicate(operation, fieldValue, isStatUnit)); case FieldEnum.Region: return(isStatUnit ? GetRegionPredicate(fieldValue) : False()); case FieldEnum.MainActivity: return(isStatUnit ? GetActivityPredicate(fieldValue): False()); default: return(base.GetPredicate(field, fieldValue, operation)); } }
static void Main(string[] args) { FieldEnum[,] board = new FieldEnum [3, 3]; FieldEnum currentSymbol = FieldEnum.X; bool gameResult = false; do { Console.WriteLine("Enter field (i,j): "); var userinput = Console.ReadLine(); int row = 0; int col = 0; if (string.IsNullOrEmpty(userinput) && userinput.Length == 3) { var rowResult = int.TryParse(userinput[0].ToString(), out row); var colResult = int.TryParse(userinput[2].ToString(), out col); if (!rowResult || colResult) { Console.WriteLine("Please enter correct data in correct format (i,j)"); continue; } if (board[row, col] != FieldEnum.Empty) { Console.WriteLine("This field is already entered"); continue; } board[row, col] = currentSymbol; currentSymbol = currentSymbol == FieldEnum.X ? FieldEnum.O : FieldEnum.X; //check if game is finished gameResult = IsGameFinished(board); } } while (gameResult); }
public void FillInFieldWith(FieldEnum fieldName, string text) { MailPage mailPage = new MailPage(); if (text == "default") { MessageEntity message = MessageEntity.GetDefaultMessageInfo(); mailPage.FillingDefaultEmailForm(message); } else { switch (fieldName) { case FieldEnum.Reciever: { mailPage.FillInRecieverField(text); break; } case FieldEnum.Theme: { mailPage.FillInThemeField(text); break; } case FieldEnum.Body: { mailPage.FillInBodyOfMessage(text); break; } default: { throw new NoSuchElementException ($"Field with '{fieldName}' name is not found"); } } } }
public Field(int value, FieldEnum type) { this.Value = value; this.Type = type; }
private static string SimpleValueExtractor(IStatisticalUnit unit, FieldEnum field) { return(unit.GetType().GetProperty(field.ToString())?.GetValue(unit, null)?.ToString() ?? string.Empty); }
public string GetValue(IStatisticalUnit unit, FieldEnum field) { return(_paramExtractors[field](unit, field)); }
static void Main(string[] args) { FieldEnum[,] board = new FieldEnum[3, 3]; var currentPlayer = FieldEnum.X; var gameFinished = false; Console.WriteLine("Hello! Welcome to the legendary game of Tic-Tac-Toe!"); Console.WriteLine("This game is for 2 players."); string firstPlayer = GetPlayerName("Please enter player nr.1 name (X): "); string secondPlayer = GetPlayerName("Please enter player nr.2 name (O): "); Console.WriteLine("Game begins!"); PrintBoard(board); do { Console.WriteLine(); Console.WriteLine($"Turn for player {currentPlayer}"); Console.Write("Please enter a row number: "); string rowInput = Console.ReadLine(); Console.Write("Please enter a column number: "); string colInput = Console.ReadLine(); //Special programmers exit with keyword STOP if (rowInput == "STOP" || colInput == "STOP") { Console.WriteLine("Game was ended by the master!"); break; } //Checking whether the row and column input is not empty if (string.IsNullOrEmpty(rowInput) || string.IsNullOrEmpty(colInput)) { WriteError("Please don't enter empty values!"); continue; } //Checking whether the input of row and columns can be converted to a number int i, j; bool rowConversion = !int.TryParse(rowInput, out i); bool colConversion = !int.TryParse(colInput, out j); if (rowConversion || colConversion) { WriteError("Please enter valid number values!"); continue; } //We have to check if the numbers are in the correct range if (i > 3 || j > 3 || i < 1 || j < 1) { WriteError("Please enter the numbers in the range [1-3]"); continue; } if (board[i - 1, j - 1] != FieldEnum.Empty) { WriteError("This field is already taken, choose another!"); continue; } board[i - 1, j - 1] = currentPlayer; PrintBoard(board); //change the current player currentPlayer = currentPlayer == FieldEnum.X ? FieldEnum.O : FieldEnum.X; gameFinished = IsGameFinished(board); } while (!gameFinished); }
/// <summary> /// Get all Fields with corresponding type. /// </summary> /// <param name="type"></param> /// <returns></returns> public IEnumerable <Field> GetFieldsByType(FieldEnum type) { return(Fields.Where(x => x.Type == type)); }
static void Main(string[] args) { //create the board using 2D array FieldEnum[,] board = new FieldEnum[3, 3]; //current player variable, it will switch at the end of each turn FieldEnum currentPlayer = FieldEnum.X; //variable which will check whether the game is finished bool gameFinished = false; //rules for players //we should define players Console.Write("Player1, what is your name: "); string player1 = Console.ReadLine(); Console.Write("Player2, what is your name: "); string player2 = Console.ReadLine(); Console.WriteLine("Game begins!"); //prepare the board PrintBoard(board); do { Console.WriteLine(); Console.WriteLine($"Player's {currentPlayer} move!"); //Gather user input for row and column Console.Write("Please input a row number: "); string rowInput = Console.ReadLine(); Console.Write("Please input a column number: "); string columnInput = Console.ReadLine(); //Special programmers exit with keyword STOP if (rowInput == "STOP" || columnInput == "STOP") { Console.WriteLine("Game was ended by the master!"); break; } //Check if the user input is not empty if (string.IsNullOrEmpty(rowInput) || string.IsNullOrEmpty(columnInput)) { Console.WriteLine("Please don't input empty values!"); continue; } //Check if the user input is of data type int int row, column; bool isRowInputANumber = int.TryParse(rowInput, out row); bool isColumnInputANumber = int.TryParse(columnInput, out column); if (!isColumnInputANumber || !isRowInputANumber) { Console.WriteLine("Please enter valid numbers!"); continue; } //Check if the user input is in the range of 1-3 if (row > 3 || row < 1 || column > 3 || column < 1) { Console.WriteLine("Please enter values in the range [1 - 3]!"); continue; } //Checking if the spot is empty if (board[row - 1, column - 1] != FieldEnum.Empty) { Console.WriteLine("This field is taken, please choose another!"); continue; } //Making the move board[row - 1, column - 1] = currentPlayer; PrintBoard(board); //Change the current player to other. X -> O and O -> X currentPlayer = currentPlayer == FieldEnum.X ? FieldEnum.O : FieldEnum.X; gameFinished = IsGameFinished(board); } while (!gameFinished); }