用戶部落格:97213529 郭益銘

97213529 郭益銘發表於2009年 01月 11日(週日) 22:16
世界任何人
virtual abstract

override new

base.X();

static

protected public private

try{} catch(Exception ex){}

int dog2;
public int dog1 { set { dog2 = value; } get { return dog2; } }

int a, b;
CallRef(ref a, ref b);
public static void CallRef(ref int x, ref int y){...}







標籤:

評論

     
    97213529 郭益銘發表於2009年 01月 11日(週日) 21:10
    世界任何人
    class Employee
    {
    private string info; //Private屬性,其他繼承的類別無法改變它的值
    public string id, name, sex, position; //其他繼承的類別可以使用這些屬性
    public int age, days, salary; //其他繼承的類別可以使用這些屬性

    public void ShowPrivateInfo() //透過繼承類別呼叫ShowPrivateInfo()
    {
    info = "This is a program about class inheritance.";

    Console.WriteLine(info);
    }

    public void ShowBaseInfo() //透過繼承類別呼叫ShowBaseInfo()
    {
    Console.WriteLine(position + "的基本資訊:") ;
    Console.WriteLine("編號:[" + id + "]");
    Console.WriteLine("姓名:[" + name + "]");
    Console.WriteLine("性別:[" + sex + "]");
    Console.WriteLine("年齡:[" + age+ "]");
    Console.WriteLine("本月工作天數:[" + days + "]");
    }
    }

    //-----------------------------------------------------------------------------------------

    class Manager : Employee //Manager繼承Employee,但薪水算法不同
    {
    public void CountSalary() //Manager的薪水計算方式:將工作天數帶入薪水計算公式
    {
    salary = 60000 + days * 1000;

    Console.WriteLine(position + "的本月薪水:[" + salary + "]");
    }
    }

    class Normal : Employee //Normal繼承Employee,但薪水算法不同
    {
    public void CountSalary() //Normal的薪水計算方式:將工作天數帶入薪水計算公式
    {
    salary = days * 1500;

    Console.WriteLine(position + "的本月薪水:[" + salary + "]");
    }
    }

    class HourCount : Employee //HourCount繼承Employee,但薪水算法不同
    {
    public void CountSalary() //HourCount的薪水計算方式:將工作天數帶入薪水計算公式
    {
    salary = days * 100 * 8 ;

    Console.WriteLine(position + "的本月薪水:[" + salary + "]");
    }
    }

    //-----------------------------------------------------------------------------------------

    class Program
    {
    static void Main(string[] args)
    {
    string choice;
    bool exit = false;

    Console.Write("請選擇要輸的的員工資訊:(a)經理 (b)一般員工 (c)時薪人員 (d)離開程式:");
    choice = Console.ReadLine();

    while (exit == false)
    {
    if (choice == "a")
    {
    Manager mm = new Manager(); //宣告一個Manager類別

    mm.position = "經理";
    mm.ShowPrivateInfo();

    //輸入經理的各項資訊
    Console.WriteLine("請輸入" + mm.position + "訊息");
    Console.Write("編號:");
    mm.id = Console.ReadLine();
    Console.Write("姓名:");
    mm.name = Console.ReadLine();
    Console.Write("性別:");
    mm.sex = Console.ReadLine();
    Console.Write("年齡:");
    mm.age = Int32.Parse(Console.ReadLine());
    Console.Write("本月工作天數:");
    mm.days = Int32.Parse(Console.ReadLine());

    Console.WriteLine("-----------------------------------------------------");

    //顯示經理的基本訊息與該月薪水
    mm.ShowBaseInfo();
    mm.CountSalary();
    }
    else if (choice == "b")
    {
    Normal nn = new Normal();

    nn.position = "一般員工";
    nn.ShowPrivateInfo();

    //輸入一般員工的各項資訊
    Console.WriteLine("請輸入" + nn.position + "訊息");
    Console.Write("編號:");
    nn.id = Console.ReadLine();
    Console.Write("姓名:");
    nn.name = Console.ReadLine();
    Console.Write("性別:");
    nn.sex = Console.ReadLine();
    Console.Write("年齡:");
    nn.age = Int32.Parse(Console.ReadLine());
    Console.Write("本月工作天數:");
    nn.days = Int32.Parse(Console.ReadLine());

    Console.WriteLine("-----------------------------------------------------");

    //顯示一般員工的基本訊息與該月薪水
    nn.ShowBaseInfo();
    nn.CountSalary();
    }
    else if (choice == "c")
    {
    HourCount hh = new HourCount();

    hh.position = "時薪人員";
    hh.ShowPrivateInfo();

    //輸入時薪人員的各項資訊
    Console.WriteLine("請輸入" + hh.position + "訊息");
    Console.Write("編號:");
    hh.id = Console.ReadLine();
    Console.Write("姓名:");
    hh.name = Console.ReadLine();
    Console.Write("性別:");
    hh.sex = Console.ReadLine();
    Console.Write("年齡:");
    hh.age = Int32.Parse(Console.ReadLine());
    Console.Write("本月工作天數:");
    hh.days = Int32.Parse(Console.ReadLine());

    Console.WriteLine("-----------------------------------------------------");

    //顯示時薪人員的基本訊息與該月薪水
    hh.ShowBaseInfo();
    hh.CountSalary();
    }
    else if (choice == "d") //按 d 離開程式
    {
    exit = true;
    break;
    }
    else //輸入錯誤時顯示錯誤訊息
    {
    Console.WriteLine("-----------------------------------------------------");
    Console.WriteLine("請輸入正確的選項或是按(d)離開程式!!");
    }

    Console.WriteLine("-----------------------------------------------------");
    Console.Write("請選擇要輸的的員工資訊:(a)經理 (b)一般員工 (c)時薪人員 (d)離開程式:");
    choice = Console.ReadLine();
    }
    }
    }

    評論

       
      97213529 郭益銘發表於2009年 01月 11日(週日) 20:40
      世界任何人
      data:
      Employee 阿狗 15.5
      Manager 阿貓 40
      code:

      using System;
      using System.IO;
      class Employee
      {

      private string name;
      protected float billingRate;
      protected float salary;

      public Employee(string name, float billingRate)
      {
      this.name = name;
      this.billingRate = billingRate;
      }

      public float CalculateCharge(float hours)
      {
      return (salary = hours * billingRate);
      }
      public float GetSalary()
      {
      return salary;
      }
      public string TypeName()
      {
      return ("Employee");
      }
      }

      class Manager : Employee
      {
      private float allowance;

      public Manager(string name, float billingRate): base(name, billingRate)
      {
      allowance = 1000;
      }
      public new float CalculateCharge(float hours)
      {
      if (hours < 1.0F)
      hours = 1.0F;
      return (salary = hours * billingRate+allowance);
      }

      public new string TypeName()
      {
      return ("Civil Employee");
      }
      }
      class Test
      {
      public static void Main()
      {
      Console.Write("請輸入檔案位置:");
      string path2 = Console.ReadLine();
      StreamReader sr = new StreamReader(@path2,System.Text.Encoding.Default);
      string str = sr.ReadToEnd();
      string[] s = str.Split('\n');
      Employee[] e = new Employee[s.Length];
      for (int i = 0; i < s.Length; i++)
      {
      string[] tmp = s[i].Split(' ');
      if (tmp[0] == "Manager")
      e[i] = new Manager(tmp[1], float.Parse(tmp[2]));
      else if (tmp[0] == "Employee")
      e[i] = new Employee(tmp[1], float.Parse(tmp[2]));
      }
      for (int i = 0; i < e.Length; i++)
      {
      e[i].CalculateCharge(i * 1.0F + 20.0F);
      Console.WriteLine("{0} charge = {1}", e[i].TypeName(), e[i].GetSalary());
      }

      }
      }

      評論

         
        97213529 郭益銘發表於2008年 12月 22日(週一) 02:39
        世界任何人

        using System;
        using System.Collections.Generic;
        using System.Text;
        using System.Collections;

        namespace ConvertTest
        {
            class zzz
            {
                public double to10(string value, int based)
                {
                    double sum = 0.0;
                    int count = 0;
                    if (value.Contains("."))
                        count = value.IndexOf('.') - 1;
                    else
                        count = value.Length - 1;
                    for (int i = 0; i < value.Length; i++) //n=>10
                        if (value[i] != '.')
                        {
                            if (char.Parse(value[i].ToString().ToUpper()) >='A')
                                sum += (char.Parse(value[i].ToString().ToUpper())-'A'+10) * Math.Pow(based, count--);
                            else
                            sum += Int32.Parse(value[i].ToString()) * Math.Pow(based, count--);
                        }
                    return sum;
                }
                public void TentoN(double sum,int gg)
                {
                    string[] arr = sum.ToString().Split('.');
                    ArrayList dog1 = new ArrayList();
                    int left = Int32.Parse(arr[0]);
                    while (left != 0)
                    {
                        dog1.Add(left % gg);
                        left /= gg;
                    }
                    dog1.Reverse();
                    if (sum.ToString().Contains("."))
                    {
                        dog1.Add(".");
                        double right = double.Parse("0." + arr[1].ToString());
                        for (int i = 0; i < 10; i++)
                        {
                            if (Math.Floor(right) == Math.Ceiling(right))
                                break;
                            right = right * gg;
                            dog1.Add(Math.Floor(right));
                            right = right - Math.Floor(right);
                        }
                    }
                    for (int i = 0; i < dog1.Count; i++)
                    {
                        if (Int32.Parse(dog1[i].ToString())>9)
                            Console.Write((char)('A' + 10 - Int32.Parse(dog1[i].ToString())));
                        else
                            Console.Write(dog1[i]);
                    }
                }
            }
            class Program
            {
                static void Main(string[] args)
                {
                    Console.Write("請輸入數值:");
                    string value = Console.ReadLine();
                    Console.Write("請輸入基底:");
                    int based = Int32.Parse(Console.ReadLine());
                    zzz dog = new zzz();
                    double sum = dog.to10(value,based);
                    Console.WriteLine("10進位是 " + sum);//10
                    //=========================TO 10==================
                    Console.Write("請輸入基底:");
                    int gg = Int32.Parse(Console.ReadLine());
                    //int a=Convert.ToInt32(arr[0]);
                    dog.TentoN(sum, gg);
                    Console.ReadKey();
                }
            }
        }

        標籤:

        評論

           
          97213529 郭益銘發表於2008年 12月 22日(週一) 01:50
          世界任何人

          using System;
          using System.Collections.Generic;
          using System.Text;

          namespace ConsoleApplication7
          {
              class matrix
              {
                  public int[,] a;
                  public matrix(int dog1,int dog2)//見夠子
                  {
                      a = new int[dog1, dog2];
                  }
                  public void insert()//書入資廖
                  {
                      Console.WriteLine("開始輸入矩陣的資料");
                      for (int i = 0; i < a.GetLength(0); i++)
                      {
                          for (int j = 0; j < a.GetLength(1); j++)
                          {
                              Console.Write("輸入第[{0},{1}] 的資料: ", i, j);
                              a[i, j] = Int32.Parse(Console.ReadLine());
                          }
                      }
                  }
                  public static matrix operator *(matrix dog1, matrix dog2) //****
                  {
                      matrix c = new matrix(dog1.a.GetLength(0),dog2.a.GetLength(1));
                   
                      for (int i = 0; i < c.a.GetLength(0); i++)
                      {
                          for (int j = 0; j < c.a.GetLength(1); j++)
                          {
                              for (int k = 0; k < dog1.a.GetLength(1); k++)
                              {
                                  c.a[i, j] += dog1.a[i, k] * dog2.a[k, j];
                              }
                          }
                      }
                      return c;
                  }
           
                  public void Print(matrix dog)
                  {
                      Console.WriteLine("a 陣列是 ");
                      for (int i = 0; i < dog.a.GetLength(0); i++)
                      {
                          for (int j = 0; j < dog.a.GetLength(1); j++)
                          {
                              Console.Write("{0} ", dog.a[i, j]);
                          }
                          Console.WriteLine();
                      }
                  }
                

              }

              class Program
              {
                 
                  static void Main(string[] args)
                  {
                      int v, x, y, z;
                      Console.WriteLine("請輸入第一個矩陣第一維度的大小");
                      v = Int32.Parse(Console.ReadLine());
                      Console.WriteLine("請輸入第一個矩陣第二維度的大小");
                      x = Int32.Parse(Console.ReadLine());

                      matrix m1 = new matrix(v, x);
                      m1.insert();

                      Console.WriteLine("請輸入第二個矩陣第一維度的大小");
                      y = Int32.Parse(Console.ReadLine());
                      Console.WriteLine("請輸入第二個矩陣第二維度的大小");
                      z = Int32.Parse(Console.ReadLine());

                      matrix m2 = new matrix(y, z);
                      m2.insert();

                      if (x == y)
                      {
                          m1.Print(m1 * m2);
                      }
                      else
                      {
                          Console.WriteLine("第一矩陣的第二維度不等於第二矩陣的第一維度,故不能相乘");
                      }

           

                  }
              }
          }

           

          評論

             
            97213529 郭益銘發表於2008年 12月 9日(週二) 10:22
            世界任何人

            select dog.Provider_no from provider dog
            where dog.Provider_no not in



            (select distinct Provider.Provider_no from



            (
            SELECT Provider.Provider_no,p1.Item_No
            FROM Provide p1,Provider
            where p1.Provider_no='001' and Provider.Provider_no not in
            (SELECT provide.Provider_no FROM Provider INNER JOIN provide ON Provider.Provider_no = provide.Provider_no where p1.Item_no = provide.Item_no)
            )



            )
            標籤:

            評論

               
              97213529 郭益銘發表於2008年 12月 4日(週四) 17:32
              97213529 郭益銘發表於2008年 12月 2日(週二) 16:36
              世界任何人

              Select Store.Sales_Region, dog from

              (Select Store.Sales_Region, SUM(Total) as dog from

              (SELECT  Sale.Store_No, SUM(Sale.Units_Sold* Item.Unit_Price) as Total

              from Sale, Item

              where Sale.Item_No = Item.Item_No group by Sale.Store_No) , Store

              where Sale.Store_No = Store.Store_No

              group by Store.Sales_Region)

              where dog =

              (Select Max(dog) from
              (Select Store.Sales_Region, SUM(Total) as dog from
              (SELECT  Sale.Store_No, SUM(Sale.Units_Sold* Item.Unit_Price) as Total

              from Sale, Item

              where Sale.Item_No = Item.Item_No group by Sale.Store_No) , Store

              where Sale.Store_No = Store.Store_No

              group by Store.Sales_Region))
              標籤:

              評論

                 
                97213529 郭益銘發表於2008年 12月 2日(週二) 15:31
                世界任何人
                Select Store_No,Total from  (SELECT Sale.Store_No, SUM(Sale.Units_Sold* Item.Unit_Price) as Total from Sale, Item where Sale.Item_No = Item.Item_No group by Sale.Store_No)
                where Total  IN (Select Max(Total) from (SELECT Sale.Store_No, SUM(Sale.Units_Sold* Item.Unit_Price) as Total from Sale, Item where Sale.Item_No = Item.Item_No group by Sale.Store_No))

                評論

                   
                  97213529 郭益銘發表於2008年 11月 17日(週一) 00:49
                  世界任何人
                  下載點1:http://moodle.ncnu.edu.tw/file.php/7345/dogC_.zip

                  下載點2:http://0rz.tw/e9516

                  //=====================鋪克牌=========================
                  ArrayList dog = new ArrayList();
                  int Rand;
                  Random rnd = new Random();
                  for (int i = 1; i <= 52; i++) //設定牌的數字
                  dog.Add(i);
                  for (int i = 0; i < 52; i++) //發5張牌
                  {
                  Rand = rnd.Next(0,dog.Count);
                  if(Convert.ToInt32(dog[Rand])%4==0)
                  Console.WriteLine("梅花{0}", Convert.ToInt32(dog[Rand]) % 13+1);
                  else if (Convert.ToInt32(dog[Rand]) % 4 == 1)
                  Console.WriteLine("方塊{0}", Convert.ToInt32(dog[Rand]) % 13+1);
                  else if (Convert.ToInt32(dog[Rand]) % 4 == 2)
                  Console.WriteLine("紅心{0}", Convert.ToInt32(dog[Rand]) % 13+1);
                  else if (Convert.ToInt32(dog[Rand]) % 4 == 3)
                  Console.WriteLine("黑桃{0}", Convert.ToInt32(dog[Rand]) % 13+1);
                  dog.RemoveAt(Rand);
                  }
                  //=====================Random===================
                  //Random dog = new Random(); //don't in for or while loop
                  //Console.WriteLine(dog.Next(2)); //0~1
                  //Console.WriteLine(dog.Next(2,4)); //2~3
                  //Console.WriteLine(dog.NextDouble()); //0.87..~1 double
                  //double dog1 = (10 - 2) * dog.NextDouble() + 2;
                  //Console.WriteLine(dog1.ToString("##.##")); //2~10 double .2
                  //======================8 to 10 進位=====================
                  //Console.Write("請輸入數值:");
                  //string value = Console.ReadLine();
                  //double sum = 0.0;
                  //int count = 0;
                  //if (value.Contains("."))
                  // count = value.IndexOf('.') - 1;//IndexOf('.')表示陣列第.個
                  //else
                  // count = value.Length - 1;
                  //for (int i = 0; i < value.Length; i++) //n=>10
                  // if (value[i] != '.')
                  // sum += Int32.Parse(value[i].ToString()) * Math.Pow(8, count--);
                  //Console.WriteLine("10進位是 " + sum);//10
                  ////=========================10 TO 8==================
                  //string[] arr = sum.ToString().Split('.');
                  //int gg = 8;
                  //ArrayList dog1 = new ArrayList();
                  //int left = Int32.Parse(arr[0]);
                  //while (left != 0)
                  //{
                  // dog1.Add(left % gg);
                  // left /= gg;
                  //}
                  //dog1.Reverse();
                  //if (sum.ToString().Contains("."))
                  //{
                  // dog1.Add(".");
                  // double right = double.Parse("0." + arr[1].ToString());
                  // for (int i = 0; i < 10; i++)
                  // {
                  // if (Math.Floor(right) == Math.Ceiling(right))
                  // break;
                  // right = right * gg;
                  // dog1.Add(Math.Floor(right));
                  // right = right - Math.Floor(right);
                  // }
                  //}
                  //for (int i = 0; i < dog1.Count; i++)
                  // Console.Write(dog1[i]);
                  //=====================尾巴compare======================
                  //Console.Write("請輸入一個字串: "); //尾巴
                  //string input = Console.ReadLine();
                  //Console.Write("請輸入一個字串: ");
                  //string input2 = Console.ReadLine();

                  //Console.Write("最大相似尾巴為: ");
                  //ArrayList dog = new ArrayList();
                  //for (int i = 1; i < Math.Min(input.Length, input2.Length); i++)
                  // if (input[input.Length - i] == input2[input2.Length - i])
                  // dog.Add(input[input.Length - i]);
                  // else
                  // break;
                  //dog.Reverse();
                  //for (int i = 0; i < dog.Count; i++)
                  // Console.Write(dog[i]);
                  //=====================middle===============
                  //int dog1; //middle
                  //string[] input = Console.ReadLine().Split(' ');
                  //dog1 = input.Length / 2;
                  //if (input.Length % 2 != 0)
                  // Console.WriteLine(input[dog1]);
                  //else
                  // Console.WriteLine((Convert.ToDouble(input[dog1]) + Convert.ToDouble(input[dog1-1])) / 2.0);
                  //=====================11010 2=>10==============
                  //char[] input = Console.ReadLine().ToCharArray(); //11010 2=>10
                  //double sum = 0;
                  //for (int i = 0; i < input.Length; i++)
                  //{
                  // sum += Convert.ToInt32(input[i].ToString()) * Math.Pow(2, input.Length - 1 - i);
                  //}
                  //Console.WriteLine(sum);
                  //=====================char+2 & char-2=============
                  //char[] input = Console.ReadLine().ToUpper().ToCharArray(); //char+2 & char-2
                  //int dog = 0;
                  //if (input[0] == '+')
                  //{
                  // for (int i = 1; i < input.Length; i++)
                  // {
                  // dog = Convert.ToInt32(input[i]) + 2;
                  // if (dog > Convert.ToInt32('Z'))
                  // Console.Write("{0}", Convert.ToChar(Convert.ToInt32('A') + dog - Convert.ToInt32('Z') - 1));
                  // else
                  // Console.Write("{0}", Convert.ToChar(dog));
                  // }
                  //}
                  //else if (input[0] == '-')
                  //{
                  // for (int i = 1; i < input.Length; i++)
                  // {
                  // dog = Convert.ToInt32(input[i]) - 2;
                  // if (dog < Convert.ToInt32('A'))
                  // Console.Write("{0}", Convert.ToChar(Convert.ToInt32('Z')-(Convert.ToInt32('A')-dog)+1));
                  // else
                  // Console.Write("{0}", Convert.ToChar(dog));
                  // }
                  //}

                  //======================//look look = ok=================
                  //Console.Write("請輸入你的資料檔 .txt 的位置 ");
                  //string path = Console.ReadLine();
                  //StreamReader sr = new StreamReader(@path);

                  //string all_line = "";
                  //while (!sr.EndOfStream)
                  //{
                  // all_line = sr.ReadLine();
                  // Console.WriteLine(all_line);
                  //}
                  ////=============================ReadToEnd=========================
                  //Console.Write("請輸入你的資料檔 .txt 的位置 ");
                  //string path = Console.ReadLine();
                  //StreamReader sr = new StreamReader(@path);
                  //string all_line = sr.ReadToEnd();
                  //string[] d = all_line.Split(' ', '\n');
                  ////===========================struct===========================
                  //struct studentinfo
                  //{
                  // public string name;
                  // public double chi_grad;
                  // public double eng_grad;
                  //};
                  //static void Main(string[] args) //<<<< //{
                  // studentinfo[] dog = new studentinfo[100];
                  // double highest = 0, lowest = 201;
                  // int highsite = 0, lowsite = 0;
                  // double chinese = 0, english = 0;
                  // int i;
                  // for (i=0; true; i++)
                  // {
                  // string[] tmp = Console.ReadLine().Split(' ');
                  // dog[i].name = tmp[0];
                  // dog[i].chi_grad = Convert.ToDouble(tmp[1]);
                  // dog[i].eng_grad = Convert.ToDouble(tmp[2]);
                  // if (dog[i].chi_grad == 0 && dog[i].eng_grad==0)
                  // break;

                  // if (dog[i].eng_grad + dog[i].chi_grad > highest)
                  // {
                  // highest = dog[i].eng_grad + dog[i].chi_grad;
                  // highsite = i;
                  // }
                  // if (dog[i].eng_grad + dog[i].chi_grad < lowest)
                  // {
                  // lowest = dog[i].eng_grad + dog[i].chi_grad;
                  // lowsite = i;
                  // Console.WriteLine(lowest);
                  // }
                  // chinese += dog[i].chi_grad;
                  // english += dog[i].eng_grad;
                  // }
                  // Console.WriteLine("最高總分的姓名與總成績 : ");
                  // Console.WriteLine("{0} {1} {2} {3} ", dog[highsite].name, dog[highsite].chi_grad + dog[highsite].eng_grad, dog[highsite].chi_grad, dog[highsite].eng_grad);

                  // Console.WriteLine("最低總分的姓名與總成績 : ");
                  // Console.WriteLine("{0} {1} {2} {3} ", dog[lowsite].name, dog[lowsite].chi_grad + dog[lowsite].eng_grad, dog[lowsite].chi_grad, dog[lowsite].eng_grad);

                  // Console.WriteLine("中文的總平均分數 {0} 分 ", chinese / i);
                  // Console.WriteLine("英文的總平均分數 {0} 分 ", english / i);
                  //}
                  Console.ReadKey();

                  評論

                     

                      
                    RSS