Skip to content

aus10code/ConsoleHelperLibrary

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ConsoleLibraryHelper

ConsoleLibraryHelper simplifies the capture of string, boolean, and number types from console users.

To use this library, add the "using ConsoleHelperLibrary" statement

Explanation

You can request either a string, boolean, or number type.

Each of the 3 types have unique requirements you can place on the data you will be requesting. If data returned by user is invalid, it will state the error and prompt the user to try again.

Some requirement examples include a minimum or maximum string length or only allowing positive numbers. They can be used individually or chained together in any order you may like

String

"What is your first name: ".RequestStringFromConsole().WithNoSpaces().Close();

RequestStringFromConsole

  • WithMinLengthOf(int minLength)
  • WithMaxLengthOf(int maxLength)
  • WithNoSpaces()
  • WithNoSpecialCharacters()
  • WithNoNumbers()
  • WithOnlyTheseOptions(List<string> options)

Number

"What is your age: ".RequestNumberFromConsole<int>.Close();
"How much money do you have: ".RequestNumberFromConsole<decimal>.WithOnlyPositives().Close();

RequestNumberFromConsole<T>

  • WithMinValueOf(T minimumValue)
  • WIthMaxValueOf(T maximumValue)
  • WithOnlyPositives()
  • WithOnlyNegatives()

Type T can be any of the following number types

  • System.Boolean
  • System.Byte
  • System.Char
  • System.Decimal
  • System.Double
  • System.SByte
  • System.Single
  • System.UInt16
  • System.UInt32
  • System.UInt64

Bool

"Are you over 18: ".RequestBoolFromConsole().Close();

The following rules are always true

  1. All methods extend objects of type string.
  2. All requirement methods begin with the keyword With
    1. i.e WithNoSpaces(), WithNoNumbers() etc..
  3. All request methods must end with a .Close()

How To Use

Request Number From Console That Is

  • An integer
  • A positive number
  • Greater than 5
  • Less than 50

Request String From Console That Contains

  • No numbers
  • No special characters
  • No white spaces

Request Boolean From Console

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages