コード例 #1
0
ファイル: Program.cs プロジェクト: Sheleh01/LAB7
 public tennis(string shop, int amount, float price) : base(shop)
 {
     /*this.amount = amount;
      * this.price = price;
      * base.Shop = shop;*/
     Name     = shop;
     tennisAm = amount;
     Price    = price;
     if (Name.Length > 30)
     {
         ExccessLongName err = new ExccessLongName("ERROR!!!\n Too long (more than 30 symbols)");
         throw err;
     }
     if (tennisAm < 0 || tennisAm > 700)
     {
         ExccessGoodAmount err = new ExccessGoodAmount("ERROR!!!\n Wrong amount");
         throw err;
     }
     for (int k = 0; k < Name.Length; k++)
     {
         if (Name[k] == '@' || Name[k] == '#' || Name[k] == '$' || Name[k] == '%' || Name[k] == '№')
         {
             ExccessInvalidSymbols err = new ExccessInvalidSymbols("ERROR!!!\n Contains invalid symbols");
             throw err;
         }
     }
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: Sheleh01/LAB7
        public Ball(string firm, string model, string shop, int amount, float price) : base(shop, amount, price)
        {
            if (firm.Length > 30)
            {
                ExccessLongName err = new ExccessLongName("ERROR!!!\n Too long (more than 30 symbols)");
                throw err;
            }
            if (model.Length > 30)
            {
                ExccessLongName err = new ExccessLongName("ERROR!!!\n Too long (more than 30 symbols)");
                throw err;
            }
            for (int k = 0; k < model.Length; k++)
            {
                if (model[k] == '@' || model[k] == '#' || model[k] == '$' || model[k] == '%' || model[k] == '№')
                {
                    ExccessInvalidSymbols err = new ExccessInvalidSymbols("ERROR!!!\n Contains invalid symbols");
                    throw err;
                }
            }
            for (int k = 0; k < firm.Length; k++)
            {
                if (firm[k] == '@' || firm[k] == '#' || firm[k] == '$' || firm[k] == '%' || firm[k] == '№')
                {
                    ExccessInvalidSymbols err = new ExccessInvalidSymbols("ERROR!!!\n Contains invalid symbols");
                    throw err;
                }
            }

            this.ballFirm  = firm;
            this.ballModel = model;
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: Sheleh01/LAB7
        public MyStruct(string firm, string model)
        {
            if (firm.Length > 30)
            {
                ExccessLongName err = new ExccessLongName("ERROR!!!\n Too long (more than 30 symbols)");
                throw err;
            }
            if (model.Length > 30)
            {
                ExccessLongName err = new ExccessLongName("ERROR!!!\n Too long (more than 30 symbols)");
                throw err;
            }
            for (int k = 0; k < model.Length; k++)
            {
                if (model[k] == '@' || model[k] == '#' || model[k] == '$' || model[k] == '%' || model[k] == '№')
                {
                    ExccessInvalidSymbols err = new ExccessInvalidSymbols("ERROR!!!\n Contains invalid symbols");
                    throw err;
                }
            }
            for (int k = 0; k < firm.Length; k++)
            {
                if (firm[k] == '@' || firm[k] == '#' || firm[k] == '$' || firm[k] == '%' || firm[k] == '№')
                {
                    ExccessInvalidSymbols err = new ExccessInvalidSymbols("ERROR!!!\n Contains invalid symbols");
                    throw err;
                }
            }

            this.firm  = firm;
            this.model = model;
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: Sheleh01/LAB7
 public Ten(string shop)
 {
     Shop = shop;
     if (Shop.Length > 30)
     {
         ExccessLongName err = new ExccessLongName("ERROR!!!\n Too long (more than 30 symbols)");
         throw err;
     }
     for (int k = 0; k < Shop.Length; k++)
     {
         if (Shop[k] == '@' || Shop[k] == '#' || Shop[k] == '$' || Shop[k] == '%' || Shop[k] == '№')
         {
             ExccessInvalidSymbols err = new ExccessInvalidSymbols("ERROR!!!\n Contains invalid symbols");
             throw err;
         }
     }
 }