Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
vangj committed Apr 20, 2023
1 parent dfee3ca commit 2b3731d
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 0 deletions.
20 changes: 20 additions & 0 deletions app2/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
internal class Program
{
private static void Main(string[] args)
{
Console.Write("light: ");
var light = Console.ReadLine();

if (light is not null) {
if (light.ToLower().Equals("red")) {
Console.WriteLine("stop");
} else if (light.ToLower().Equals("yellow")) {
Console.WriteLine("slow");
} else if (light.ToLower().Equals("green")) {
Console.WriteLine("go");
} else {
Console.WriteLine($"I don't know the color {light}");
}
}
}
}
10 changes: 10 additions & 0 deletions app2/app2.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
23 changes: 23 additions & 0 deletions app3/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
internal class Program
{
private static void Main(string[] args)
{
Console.Write("height: ");
var height = Console.ReadLine();

Console.Write("width: ");
var width = Console.ReadLine();

if (height is not null && width is not null) {
try {
int h = Int32.Parse(height);
int w = Int32.Parse(width);
int a = h * w;

Console.WriteLine($"h={h}, w={w}, a={a}");
} catch (Exception e) {
Console.WriteLine(e);
}
}
}
}
10 changes: 10 additions & 0 deletions app3/app3.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
36 changes: 36 additions & 0 deletions app4/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
internal class Program
{
private static void Main(string[] args)
{
while (true)
{
Console.Write("height: ");
var height = Console.ReadLine();

Console.Write("width: ");
var width = Console.ReadLine();

if (height is not null && width is not null)
{
if (height.ToLower().Equals("q") || width.ToLower().Equals("q")) {
break;
}

try
{
int h = Int32.Parse(height);
int w = Int32.Parse(width);
int a = h * w;

Console.WriteLine($"h={h}, w={w}, a={a}");
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
}

Console.WriteLine("bye, see you later");
}
}
10 changes: 10 additions & 0 deletions app4/app4.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
29 changes: 29 additions & 0 deletions app5/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
internal class Program
{
private static void Main(string[] args)
{
Random random = new Random();

while (true) {
Console.Write("guess: ");
var guess = Console.ReadLine();

if (guess is not null) {
if (guess.ToLower().Equals("q")) {
break;
}

var num = random.Next(0, 2);
var g = Int32.Parse(guess);

if (num == g) {
Console.WriteLine("correct!");
} else {
Console.WriteLine($"incorrect! guess={guess}, number={num}");
}
}
}

Console.WriteLine("bye, please play again!");
}
}
10 changes: 10 additions & 0 deletions app5/app5.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>

0 comments on commit 2b3731d

Please sign in to comment.