Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace ConsoleApp1;
- using System.Text;
- public class Task14
- {
- public void Run()
- {
- Console.InputEncoding = Encoding.Unicode;
- Console.OutputEncoding = Encoding.Unicode;
- bool canExit = false;
- while ( canExit == false )
- {
- Console.Clear();
- Console.WriteLine( $"Input name" );
- string name = Console.ReadLine();
- int nameWidth = name.Length;
- Console.Write( $"Input border char: " );
- char borderChar = Console.ReadKey().KeyChar;
- int borderThickness = 1;
- int borderLeftThickness = borderThickness;
- int borderRightThickness = borderThickness;
- int borderWidth = borderLeftThickness + nameWidth + borderRightThickness;
- int borderHeight = 3;
- int nameRowIndex = 1;
- Console.WriteLine();
- for ( int rowIndex = 0; rowIndex < borderHeight; rowIndex++ )
- {
- string line;
- if ( rowIndex == nameRowIndex )
- {
- string borderPart = new string( borderChar, borderThickness );
- line = $"{borderPart}{name}{borderPart}";
- }
- else
- {
- line = new string( borderChar, borderWidth );
- }
- Console.WriteLine( line );
- }
- Console.WriteLine();
- string properlyExitAnswer = "n";
- Console.WriteLine( $"Continue? Enter \'{properlyExitAnswer}\' for exit" );
- string continueAnswer = Console.ReadLine();
- canExit = string.Equals( continueAnswer, properlyExitAnswer );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement