Help Me! C# Question

Nov 9 2009 4:22 PM
Help me! notice Error:
"Error    1    'ConsoleApplication1.Matrix' does not contain a constructor that takes '0' arguments    C:\Users\Mr Neo\AppData\Local\Temporary Projects\ConsoleApplication1\Program.cs    306    24    ConsoleApplication1"


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ConsoleApplication1
{
    class Matrix
    {
        private int dong;
        private int cot;
        public int posCol;
        public int posRow;

        public int Dong
        {
            get
            {
                return dong;
            }
            set
            {
                dong = value;
            }
        }
        public int Cot
        {
            get
            {
                return cot;
            }
            set
            {
                cot = value;
            }
        }
        public int[,] mt;
        public Matrix(int d, int c)
        {
            Dong = d;
            Cot = c;
            mt=new int[3,3];

        }
        public void nhap()
        {
            for (int i = 0; i <=3; i++)
            {
                for (int j = 0; j <=3; j++)
                {
                nhaplai:
                    try
                    {
                        Console.WriteLine("nhap vao phan tu thu a[{0}][{1}]:",i,j);
                        mt[i, j] = int.Parse(Console.ReadLine());
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Loi:\t"+e.Message);
                        goto nhaplai;
                        throw;
                    }
                }
            }
        }
        public void xuat()
        {
            for (int i = 0; i <=3 ; i++)
            {
                for (int j = 0; j <=3 ; j++)
            {
                Console.WriteLine("\t",mt[i,j]);
            }
                Console.WriteLine("\n");
            }
        }
        public int this[int dong, int cot]
        {
            get
            {
                for (int i = 0; i <=3; i++)
                {
                    for (int j = 0; j <=3; j++)
                    {
                        if (dong==i&&cot==j)
                        {
                            return mt[i, j];
                        }
                    }
                }
                return -100;
            }
        }
        public void matrix()
        {
            mt = new int[3, 3];
            Random r = new Random();
            mt[0, 0] = 1; mt[0, 1] = 0; mt[0, 2] = 2;
            mt[1, 0] = 3; mt[1, 1] = 4; mt[1, 2] = 5;
            mt[2, 0] = 6; mt[2, 1] = 7; mt[2, 2] = 8;
            posCol = 1;
            posRow = 0;
            mt[posCol, posRow] = 0;
        }
        public bool checkwin()
        {
            bool flag = true;
            for (int i = 0; i <=3; i++)
            {
                if (!(mt[i,0]<mt[i,1]&&mt[i,1]<mt[i,2]))
                {
                    flag=false;
                    break;

                }
            }
            for (int j = 0; j <=3; j++)
            {
             if (!(mt[0,j]<mt[1,j]&&mt[1,j]<mt[2,j]))
                {
                    flag = false;
                    break;
                }
            }
            return flag;
        }
        public void Writedata()
        {
            int count = 0;
            string dateplay = DateTime.Now.ToString("dd:mm:yyy");
            FileStream fs = new FileStream("C:\\test.txt",FileMode.Append,FileAccess.Write,FileShare.Read);
            StreamWriter sw = new StreamWriter(fs);
            // ghi thong tin nguoi choi
            //ghi thong tin nguoi choi
            sw.WriteLine("Thong Tin Nguoi Choi Truoc La:");
            sw.WriteLine("Name:");
            sw.WriteLine("Tuoi:");
            sw.WriteLine("Ngay Choi:" + dateplay);
            sw.WriteLine("so LAN DI CHUYEN:" + count++);
            sw.Flush();
            sw.Close();
            fs.Close();
        }
        public void docdata()
        {
            FileStream fs = new FileStream("C:\\test.txt",FileMode.Open,FileAccess.Read,FileShare.Read);
            StreamReader sd = new StreamReader(fs);
            string str = Console.ReadLine();

            while (str != null)
            {
                Console.WriteLine("{0}", str);
                str = sd.ReadLine();
                sd.Close();
                fs.Close();
            }
        }
        public void nhapttnguoichoi()
        {
            string Ten;
            int Tuoi;
            Console.WriteLine("\n\t\t***Moi Ban Nhap Nhung Thong Tin Co Ban De Bat Dau Choi***");
            Console.WriteLine("\nMoi Ban Nhap Ten:");
            Ten = Console.ReadLine();
            Console.WriteLine("\nMoi Ban Nhap Tuoi:");
            Tuoi = Convert.ToInt32(Console.ReadLine());
            FileStream fs = new FileStream("C:\\Game_Shuffle.txt", FileMode.Append, FileAccess.Write, FileShare.None);
            StreamWriter sw = new StreamWriter(fs);
            while (Tuoi <= 0 || Tuoi > 130)
            {
                Console.WriteLine("Ban nhap sai so tuoi-De nghi ban nhap lai");
                Tuoi = Convert.ToInt32(Console.ReadLine());
            }
            //ghi thong tin nguoi choi
          
        }
        public void play()
        {
            string sPos;
            bool bRet;
            int Count = 0;
            nhapttnguoichoi();
            do
            {
                Console.Clear();
                Console.WriteLine("....Start...");
                xuat();
                Console.WriteLine("\n\n\n\t\t............Menu......\n\n");
                Console.WriteLine("                  ***Press L or l De di Chuyen Sang Trai");
                Console.WriteLine("                  ***Press R or r De di Chuyen Sang Phai");
                Console.WriteLine("                  ***Press U or u De di Chuyen Len Tren");
                Console.WriteLine("                  ***Press D or d De di Chuyen Xuong Duoi");
                Console.WriteLine("                  ***Press E Ket Thuc Chuong trinh");
                Console.WriteLine("\n\n\t.....................................................\n\n");
                sPos = Console.ReadLine();
                Count++;
                switch (sPos)
                {
                    case "E":
                    case "e":
                        break;
                    case "R":
                    case "r":

                        if (posCol == 2)
                            Console.WriteLine("Ban khong the di chuyen ra ngoai Ma tran");
                        else
                        {
                            mt[posRow, posCol] = mt[posRow, posCol + 1];
                            mt[posRow, posCol + 1] = 0;
                            posCol++;
                            Count++;
                            xuat();
                            bRet = checkwin();
                            if (bRet == true)
                            {
                                Console.WriteLine("Ban da ginh chien thang-xin chuc mung ban!!!");
                                sPos = "E";
                                sPos = "e";
                                break;
                            }
                        }
                        break;
                    case "L":
                    case "l":

                        if (posCol == 0)
                            Console.WriteLine("Ban khong the di chuyen ra ngoai Ma tran");
                        //Console.ReadLine();
                        else
                        {
                            mt[posRow, posCol] = mt[posRow, posCol - 1];
                            mt[posRow, posCol - 1] = 0;
                            posCol--;
                            Count++;
                            xuat();
                            bRet = checkwin();
                            if (bRet == true)
                            {
                                Console.WriteLine("Ban da ginh chien thang-xin chuc mung ban!!!");
                                sPos = "E";
                                sPos = "e";
                                break;
                            }

                        }
                        break;
                    case "U":
                    case "u":

                        if (posRow == 0)
                            Console.WriteLine("Ban khong the di chuyen ra ngoai Ma tran");
                        else
                        {
                            mt[posRow, posCol] = mt[posRow - 1, posCol];
                            mt[posRow - 1, posCol] = 0;
                            posRow--;
                            Count++;
                            xuat();
                            bRet = checkwin();
                            if (bRet == true)
                            {
                                Console.WriteLine("Ban da ginh chien thang-xin chuc mung ban!!!");
                                sPos = "E";
                                sPos = "e";
                                break;
                            }
                        }
                        break;
                    case "D":
                    case "d":

                        if (posRow == 2)
                            Console.WriteLine("Ban khong the di chuyen ra ngoai Ma tran");
                        else
                        {
                            mt[posRow, posCol] = mt[posRow + 1, posCol];
                            mt[posRow + 1, posCol] = 0;
                            posRow++;
                            Count++;
                            xuat();
                            bRet =checkwin();
                            if (bRet == true)
                            {
                                Console.WriteLine("Ban da ginh chien thang-xin chuc mung ban!!!");
                                sPos = "E";
                                sPos = "e";
                                break;
                            }
                        }
                        break;

                }
            }
            while (sPos != "E");

            Console.ReadLine();

        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            Matrix h = new Matrix();
            h.nhap();
            h.xuat();
            h.Writedata();
            h.nhapttnguoichoi();
            h.matrix();
            h.docdata();
            h.checkwin();
            h.play();
            Console.ReadLine();
        }
    }
}

Fault is marked here in bold


Answers (1)