# 物件導向程式設計實習
## 2024124
### 第一題

### 第二題

### 第三題

### 第四題

### 心得
在這一次的課程,我學到了很多關於c#的語法,在c++裡面語法大部分都算很短的,但在c#裡面,雖然裡面跟c++很多都很像,還是有些許的不一樣,像是輸出文字,就變得非常的長,雖然我還是覺得這一學期學的還蠻麻煩跟困難的,但我還是會努力去把這一學期學好的
## 2024221
### 練習1
```
Console.Write("請輸入你的名字");
string name = Console.ReadLine();
Console.WriteLine($"Good Day!{name}");
```

### 練習二
```
Console.Write("請輸入名稱:");
string? name = Console.ReadLine();
Console.Write("請輸入提款金額:");
int money = Convert.ToInt32(Console.ReadLine());
Console.WriteLine($"Hi! {name}, 提款金額:{money:C0}");
```


### 練習3


## 20240306
### 1
```
using static System.Console;
WriteLine("資訊一甲 14 洪維澤");
WriteLine(" ");
int num1 = 1_23_456;
long num2 = 465_789_123l;
long max = Int64.MaxValue;
long min = Int64.MinValue;
int num3 = 0b1011_110;
int num4 = 0b_111_110_10;
int num5 = 0x_FB12;
WriteLine($"Number: {num1:NO}, {num2:n0}");
WriteLine($"二進位變十進位 : {num3:D5}, {num4:D4}, {num5:D6}");
WriteLine($".NET Framework型別(num1): {num1.GetType()}");
WriteLine($".NET Framework型別(num2): {num1.GetType()}");
WriteLine($"Max:{max}");
WriteLine($"Min:{min}");
```


### 2
```
using static System.Console;
WriteLine("資訊一甲 14 洪維澤");
WriteLine(" ");
float num1 = 1.2233445566778899F;
double num2 = 1.2233445566778899;
decimal num3 = 1.2233445566778899m;
double x1 = 0.1, x2 = 0.2;
decimal y1 = 0.1m, y2 = 0.2m;
WriteLine($"Float : {num1}");
WriteLine($"Double : {num2}");
WriteLine($"Decimal : {num1}");
WriteLine($"Float: {num1:f4}");
WriteLine($"Double 佔<{sizeof(double)}>位元組");
WriteLine($"Decimal 佔<{sizeof(decimal)}>位元組");
WriteLine($"double, x1 + x2 = {x1 + x2}");
WriteLine($"decimal, y1 + y2 = {y1 + y2}");
```


### 3
```
using static System.Console;
WriteLine("資訊一甲 14 洪維澤");
WriteLine(" ");
const float Square = 3.0579f;
Write("請輸入坪數");
float area = Convert.ToSingle(Square);
WriteLine($"{area}坪 = {Square *area}");
const float PI = 3.14159F;
const float Circular = PI * 25.0F;
WriteLine($"園面積 ->{Circular}");
```


### 4
```
using static System.Console;
WriteLine("資訊一甲 14 洪維澤");
WriteLine(" ");
Write("請輸入你的生日");
string birth = ReadLine();
DateTime special = Convert.ToDateTime(birth);
DateTime Atonce =DateTime.Now;
string thisday =Convert.ToString(Atonce);
WriteLine($"今天是{thisday}\n你的生日{special}");
```

## 2024313
### 第一題
### 第二題
```
namespace WindowsFormsApp2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
try
{
int i = Convert.ToInt32(textBox3.Text);
label6.Text = $"提款金額: {i:N} 元";
}
catch
{
MessageBox.Show("請輸入整數!", "注意",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
private void Form1_Load(object sender, EventArgs e)
{
string uname = Microsoft.VisualBasic.Interaction.InputBox("請輸入姓名", "輸入");
DialogResult dr = MessageBox.Show(uname + "歡銀你", "歡迎",
MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
Text = uname;
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
}
}
```


## 2024320
### 第一題
```
// See https://aka.ms/new-console-template for more information
//Console.WriteLine("Hello, World!");
using static System.Console;
int sum = 0, count = 0;
for (; ; )
{
Write("請輸入數值作加總");
int number =Convert.ToInt32(Console.ReadLine());
count++;
sum += number;
Write("還要繼續嗎?(Y繼續N離開)");
string? endkey = ReadLine();
if (endkey == "Y" || endkey == "y")
continue;
else if (endkey == "N" || endkey == "n")
break;
}
WriteLine($"輸入{count}個數字,合計{sum}");
ReadKey();
```


## 2024327
### 第一題
```
string[] name = {"Molly", "Eric", "Johseph",
"Peter", "Iron", "Priyanka"};
int[] age = { 24, 26, 24, 26, 28, 25 };
int index = Array.IndexOf(age, 24);
Console.WriteLine("---年齡符合24歲---\n");
while (index >= 0)
{
Console.WriteLine($" {name[index],-8}");
index = Array.IndexOf(age, 24, index + 1);
}
Array.Sort(age);
var key = Array.BinarySearch(age, 25);
switch (key)
{
case >= 0:
Console.WriteLine($"\n找到年齡25 ! 位置 ={key}");
break;
default:
Console.WriteLine($"\n未找到年齡25 ! 位置 = {key}");
break;
}
```


### 第二題
```
int outer, inner;
int[] sum = new int[3];
string[] name = { "Marry", "Tomas", "John" };
foreach (string item in name)
Console.WriteLine("{0,7}", item);
Console.WriteLine();
int[,] score = { {75,64, 96 }, {55,67,39 },
{45,92,85 },{71,69,81}};
int row = score.GetLength(0);
int column = score.GetLength(1);
for (outer = 0; outer<row; outer++)
{
for (inner =0; inner < column; inner++)
Console.WriteLine($"{score[outer, inner],7} ");
Console.WriteLine( );
sum[0] += score[outer, 0];
sum[1] += score[outer, 1];
sum[2] += score[outer, 2];
}
Console.WriteLine("--------------------");
Console.WriteLine($"Sum: {sum[0]} {sum[1],5} {sum[2],6}");
```


### 第三題
```
int[,,] num3D = new int[2, 2, 3] {
{{11,13,15},{22,24,26} },
{{33,38,41},{44,48,52} }};
Console.WriteLine($"元素:{num3D[1,1,1]}, "+
$"位於第2個表格,位於第二列第二攔\n");
int table = num3D.GetLength(0);
int row = num3D.GetLength(1);
int column = num3D.GetLength(2);
Console.WriteLine($"表格{table} 個, 二為表格{row}*{column}\n");
for (int first = 0; first < table; first++)
{
Console.WriteLine($"---表格{first + 1}----");
for (int second = 0; second < column; second++)
{
for (int thrid = 0; thrid < column; thrid++)
Console.WriteLine($"{num3D}[first, second,thrid],3 |");
Console.WriteLine();
}
Console.WriteLine();
}
```

## 20240410
### 第一題
```
```
### 第二題
```
```
## 20240417
### 第三題
```
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start("C:\\c\\test\\test\\bin\\Debug");
}
private void Form1_Load(object sender, EventArgs e)
{
linkLabel2.LinkColor = Color.DarkOrchid;
linkLabel2.ActiveLinkColor = Color.Yellow;
linkLabel2.LinkVisited = true;
linkLabel2.VisitedLinkColor = Color.Maroon;
linkLabel2.LinkBehavior = LinkBehavior.HoverUnderline;
linkLabel2.Text = "Visual Studio Web";
linkLabel2.LinkArea = new LinkArea(0, 6);
}
private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start("https://www.youtube.com/watch?v=5OWvkadoV-M");
}
}
}
```

