oo-70-245-1

oo-70-245-1 Commit Details


Date:2014-08-30 22:07:05 (10 years 1 month ago)
Author:Natalie Adams
Branch:master
Commit:13f06a690083c0fb8378323f42102cb16d088f30
Parents: 2e928509043c5ac5aa610ba098a4d5e884def0a9
Message:Adding Day 1 class examples

Changes:

File differences

Day 1 Class Examples/example1/Program.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace example1
{
class Program
{
private int x;
protected int y;
public int z;
static void Main(string[] args)
{
Console.WriteLine("Hello world");
//Test t = new Test();
//t
string s = "hello, ";
s += "world";
Console.WriteLine("hello, " + s + s + s + "some other string" + s + "something");
Console.WriteLine("hello, {0.2} {1} {2} {3}", s, s, s, s);
}
}
class Test : Program
{
}
}
Day 1 Class Examples/example2/Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace example2
{
class Program
{
static void Main(string[] args)
{
int n1, n2;
Console.WriteLine("Please enter 2 numbers");
n1 = Int32.Parse(Console.ReadLine());
n2 = Int32.Parse(Console.ReadLine());
Console.WriteLine("{0} + {1} = {2}", n1, n2, n1 + n2);
Console.WriteLine("{0} * {1} = {2}", n1, n2, n1 * n2);
Console.WriteLine("{0} / {1} = {2}", n1, n2, n1 / n2);
Console.WriteLine("{0} - {1} = {2}", n1, n2, n1 - n2);
Console.Read();
}
}
}
Day 1 Class Examples/example3/Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace example3
{
class Program
{
static void Main(string[] args)
{
int tal = 0;
string tmp;
Console.WriteLine("Please enter 5 numbers:");
for (int i = 0; i < 5; i++)
{
tmp = Console.ReadLine();
tal += Int32.Parse(tmp);
}
Console.WriteLine("Value of tal = {0}", tal);
}
}
}
Day 1 Class Examples/example4/Program.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace example4
{
class Math
{
public int pow(int num, int power)
{
int tmp = 1;
for(int i = 0; i < power; i++)
{
tmp *= num;
}
return tmp;
}
}
class Program
{
static void Main(string[] args)
{
int n2;
int n1;
Console.WriteLine("Please enter a number and a power:");
n1 = Int32.Parse(Console.ReadLine());
n2 = Int32.Parse(Console.ReadLine());
Math m = new Math();
Console.WriteLine("The value is {0}", m.pow(n1, n2));
}
}
}
Day 1 Class Examples/example5/Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace example5
{
class Program
{
static int fact(int n)
{
if (n == 0)
return 1;
else
return n * fact(n - 1);
}
static void Main(string[] args)
{
Console.WriteLine("{0}", fact(3));
}
}
}

Archive Download the corresponding diff file

Branches

Number of commits:
Page rendered in 0.08540s using 14 queries.