blob: a5a2a51606737e3a986afb61da6b5498b0d7bafb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
/*
* Created by: Mo Khan
* Created: Saturday, May 26, 2007
*/
using System;
namespace Sait.Cmpp297.Assignment1.AsterikPatterns {
internal class Program {
#region Public Methods
public static void Main( ) {
OutputAC( delegate( Int32 xAxis, Int32 i ) { return ( xAxis < i + 1 ); } );
OutputBD( delegate( Int32 xAxis, Int32 i ) { return ( xAxis < i ); } );
OutputAC( delegate( Int32 xAxis, Int32 i ) { return ( xAxis >= i ); } );
OutputBD( delegate( Int32 xAxis, Int32 i ) { return ( i <= xAxis + 1 ); } );
Console.ReadLine( );
}
#endregion
#region Private Fields
private delegate Boolean CheckCondition( Int32 xAxis, Int32 charactersPerRow );
#endregion
#region Private Methods
private static void OutputAC( CheckCondition condition ) {
Int32 charactersPerRow = 0;
// loop through the y axis from row 0 to 10
for ( int yAxis = 0; yAxis < 10; yAxis++ ) {
// loop through x axis from column 0 to 10 for each row.
for ( int xAxis = 0; xAxis < 10; xAxis++ ) {
// write the character for the current position
Console.Write( condition( xAxis, charactersPerRow ) ? "*" : " " );
}
++charactersPerRow;
Console.WriteLine( );
}
}
private static void OutputBD( CheckCondition condition ) {
Int32 charactersPerRow = 10;
for ( int yAxis = 0; yAxis < 10; yAxis++ ) {
for ( int xAxis = 0; xAxis < 10; xAxis++ ) {
Console.Write( condition( xAxis, charactersPerRow ) ? "*" : " " );
}
--charactersPerRow;
Console.WriteLine( );
}
}
#endregion
}
}
|