-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3cb449a
commit 3a0ef29
Showing
3 changed files
with
161 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Labsheet07 | ||
{ | ||
class DigitArt | ||
{ | ||
const int WIDTH = 6; | ||
const int HEIGHT = 6; | ||
const int SPACE_BETWEEN_CHARACTER = 2; | ||
|
||
public Dictionary<char, string[]> Template => _template; | ||
Dictionary<char, string[]> _template; | ||
|
||
|
||
public DigitArt() | ||
{ | ||
_initialize(); | ||
} | ||
|
||
public void WriteLine(string value) | ||
{ | ||
for (int row = 0; row < HEIGHT; row++) | ||
{ | ||
var result = String.Empty; | ||
|
||
foreach (char character in value) | ||
{ | ||
for (int i = 0; i < SPACE_BETWEEN_CHARACTER; i++) { | ||
result += " "; | ||
} | ||
|
||
var digitText = _template[character]; | ||
result += digitText[row]; | ||
} | ||
|
||
Console.WriteLine(result); | ||
} | ||
} | ||
|
||
void _initialize() | ||
{ | ||
_template = new Dictionary<char, string[]>(); | ||
|
||
_template.Add('0', new string[HEIGHT]); | ||
_template['0'][0] = " ** "; | ||
_template['0'][1] = "* *"; | ||
_template['0'][2] = "* *"; | ||
_template['0'][3] = "* *"; | ||
_template['0'][4] = "* *"; | ||
_template['0'][5] = " ** "; | ||
|
||
_template.Add('1', new string[HEIGHT]); | ||
_template['1'][0] = " * "; | ||
_template['1'][1] = " ** "; | ||
_template['1'][2] = " * * "; | ||
_template['1'][3] = " * "; | ||
_template['1'][4] = " * "; | ||
_template['1'][5] = " * "; | ||
|
||
_template.Add('2', new string[HEIGHT]); | ||
_template['2'][0] = " *****"; | ||
_template['2'][1] = " *"; | ||
_template['2'][2] = " *****"; | ||
_template['2'][3] = "* "; | ||
_template['2'][4] = "* "; | ||
_template['2'][5] = "******"; | ||
|
||
_template.Add('3', new string[HEIGHT]); | ||
_template['3'][0] = " *****"; | ||
_template['3'][1] = " *"; | ||
_template['3'][2] = " *****"; | ||
_template['3'][3] = " *"; | ||
_template['3'][4] = " *"; | ||
_template['3'][5] = " *****"; | ||
|
||
_template.Add('4', new string[HEIGHT]); | ||
_template['4'][0] = " * "; | ||
_template['4'][1] = " * * "; | ||
_template['4'][2] = " *****"; | ||
_template['4'][3] = " * "; | ||
_template['4'][4] = " * "; | ||
_template['4'][5] = " * "; | ||
|
||
_template.Add('5', new string[HEIGHT]); | ||
_template['5'][0] = " *****"; | ||
_template['5'][1] = " * "; | ||
_template['5'][2] = " *****"; | ||
_template['5'][3] = " *"; | ||
_template['5'][4] = " *"; | ||
_template['5'][5] = " *****"; | ||
|
||
_template.Add('6', new string[HEIGHT]); | ||
_template['6'][0] = " *****"; | ||
_template['6'][1] = " * "; | ||
_template['6'][2] = " *****"; | ||
_template['6'][3] = " * *"; | ||
_template['6'][4] = " * *"; | ||
_template['6'][5] = " *****"; | ||
|
||
_template.Add('7', new string[HEIGHT]); | ||
_template['7'][0] = " *****"; | ||
_template['7'][1] = " *"; | ||
_template['7'][2] = " *"; | ||
_template['7'][3] = " *"; | ||
_template['7'][4] = " *"; | ||
_template['7'][5] = " *"; | ||
|
||
_template.Add('8', new string[HEIGHT]); | ||
_template['8'][0] = " *****"; | ||
_template['8'][1] = " * *"; | ||
_template['8'][2] = " *****"; | ||
_template['8'][3] = " * *"; | ||
_template['8'][4] = " * *"; | ||
_template['8'][5] = " *****"; | ||
|
||
_template.Add('9', new string[HEIGHT]); | ||
_template['9'][0] = " *****"; | ||
_template['9'][1] = " * *"; | ||
_template['9'][2] = " *****"; | ||
_template['9'][3] = " *"; | ||
_template['9'][4] = " *"; | ||
_template['9'][5] = " *****"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,44 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Labsheet07 | ||
{ | ||
class Program | ||
{ | ||
const string DEFAULT_TEXT = "0123456789"; | ||
const string ACTUAL_TEXT = "6002526"; | ||
|
||
DigitArt digitArt; | ||
|
||
|
||
public Program() | ||
{ | ||
Console.Title = String.Format("Labsheet07 - Print multiline number : {0}", ACTUAL_TEXT); | ||
digitArt = new DigitArt(); | ||
} | ||
|
||
void Run() | ||
{ | ||
Console.WriteLine("----------"); | ||
Console.WriteLine("All template..."); | ||
Console.WriteLine("----------"); | ||
|
||
digitArt.WriteLine(DEFAULT_TEXT); | ||
|
||
Console.WriteLine(); | ||
Console.WriteLine(); | ||
|
||
Console.WriteLine("----------"); | ||
Console.WriteLine("Actual Text : "); | ||
Console.WriteLine("----------"); | ||
|
||
digitArt.WriteLine(ACTUAL_TEXT); | ||
|
||
Console.ReadLine(); | ||
} | ||
|
||
static void Main(string[] args) | ||
{ | ||
new Program().Run(); | ||
} | ||
} | ||
} | ||
} |