Abdula_2314124

Untitled

Mar 5th, 2024
896
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.55 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Metho
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             float speed = 20;
  10.             float distance = 3000;
  11.  
  12.             int time = 30;
  13.             int directionX = 1;
  14.             int directionY = 0;
  15.  
  16.             string direction = "";
  17.  
  18.             SetDirection(directionX, directionY, ref direction);
  19.  
  20.             Move(speed, time, distance, direction);
  21.         }
  22.  
  23.         static void Method()
  24.         {
  25.             Console.WriteLine("Message methoda");
  26.         }
  27.  
  28.         // speed, час, дистанція яку треба пройти, направлення
  29.         static void Move(float speed, int time, float distance,
  30.             string direction)
  31.         {
  32.             Console.WriteLine($"Player move direction {direction}," +
  33.                 $" speed {speed} " +
  34.                 $"time {time}, distance {distance}");
  35.         }
  36.  
  37.         static void SetDirection(int directionX, int directionY, ref string direction)
  38.         {
  39.             if (directionX == 1 && directionY == 0)
  40.             {
  41.                 direction = "Вправо";
  42.             }
  43.             else if (directionX == 0 && directionY == 1)
  44.             {
  45.                 direction = "Вверх";
  46.             }
  47.             else if (directionX == -1 && directionY == 0)
  48.             {
  49.                 direction = "Вліво";
  50.             }
  51.             else if (directionX == 0 && directionY == -1)
  52.             {
  53.                 direction = "Вниз";
  54.             }
  55.         }
  56.     }
  57. }
  58.  
Advertisement
Add Comment
Please, Sign In to add comment