Esempio n. 1
0
        static void Guest()
        {
            Regular Rnewmember;

            Rnewmember = new Regular();

            Console.Clear();
            // Input from user about name
            Console.WriteLine("Enter your name:");
            Rnewmember.name = Convert.ToString(Console.ReadLine());
            // Input from user about address
            Console.WriteLine("Enter your address:");
            Rnewmember.address = Convert.ToString(Console.ReadLine());
            // Input from user about telephone
            Console.WriteLine("Enter your telephone number:");
            Rnewmember.telephone = Convert.ToInt32(Console.ReadLine());
            // Input from user about Payment
            Console.WriteLine("Enter your Payment method:");
            Rnewmember.PaymentM = Convert.ToString(Console.ReadLine());

            Package();

            Console.Clear();

            Console.WriteLine("Name: {0}", Rnewmember.name);
            Console.WriteLine("Address: {0}", Rnewmember.address);
            Console.WriteLine("Telephone: {0}", Rnewmember.telephone);
            Console.WriteLine("Payment Method: {0}", Rnewmember.PaymentM);
            Console.WriteLine("Shipment Cost: {0}");

            // Console.ReadKey();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Gold Gnewmember;

            Gnewmember = new Gold();

            Regular Rnewmember;

            Rnewmember = new Regular();

            int choice = 0;

            DisplayMenu();
            choice = Convert.ToInt32(Console.ReadLine());

            if (choice == 1)
            {
                Guest();
            }
            if (choice == 2)
            {
                Console.WriteLine("2");
            }
            if (choice != 1 || choice != 2)
            {
                Console.WriteLine("The variable is set to false.");
            }
        }
Esempio n. 3
0
        private void AgregarTipoBomba()
        {
            byte opcion = 0;

            WriteTitle("Tipo de Bomba");
            WriteLine("1. Súper");
            WriteLine("2. Regular");
            WriteLine("3. Diesel");
            WriteLine("0. Salir");
            WriteLine("Seleccione una opción ==> ");
            string respuesta = ReadLine();

            if (respuesta.Equals("1"))
            {
                Bomba super = new Super();
                AgregarElemento(super);
            }
            else if (respuesta.Equals("2"))
            {
                Bomba regular = new Regular();
                AgregarElemento(regular);
            }
            else if (respuesta.Equals("3"))
            {
                Bomba diesel = new Diesel();
                AgregarElemento(diesel);
            }
        }
Esempio n. 4
0
        private void agregarTipoBomba()
        {
            Clear();
            WriteTitle("Administracion de Bombas");
            WriteTitle("Tipo de Bomba");
            WriteLine("1. Super");
            WriteLine("2. Regular");
            WriteLine("3. Diesel");
            WriteLine("0. Salir");
            WriteLine("Seleccione una Opcion==>");
            string respuesta = ReadLine();

            if (respuesta.Equals("1"))
            {
                Bomba super = new Super();
                agregarElemento(super);
            }
            else if (respuesta.Equals("2"))
            {
                Bomba regular = new Regular();
                agregarElemento(regular);
            }
            else if (respuesta.Equals("3"))
            {
                Bomba diesel = new Diesel();
                agregarElemento(diesel);
            }
        }
Esempio n. 5
0
        private void Login_in_Button_Click(object sender, RoutedEventArgs e)//登录信息写完点下一步
        {
            Regular user = (Regular)dbManger.GetUser(textBlock_phone.Text, UserGroup.REGULAR);

            //如果用户名手机号已经存在,说明该用户已存在,可直接登录
            if (user != null)
            {
                if (Encryptor.GetMD5(textBlock_password.Password) == user.Password)
                {
                    PageList.Main.setPage(PageList.Questionandgame);
                }
                else
                {
                    CustomMessageBox.Show("温馨提示:", "Password Error!");
                }
            }
            else//用户手机号不存在,提示请先注册
            {
                CustomMessageBox.Show("温馨提示:", "Please Sign In !");
                Login.Visibility            = System.Windows.Visibility.Hidden;
                Register.Visibility         = System.Windows.Visibility.Visible;
                textBlock_phone.Text        = "";
                textBlock_password.Password = "";
            }
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            Mystery mystery1 = new Mystery("KC02122006", 13, "Female", "Drapery");
            Mystery mystery2 = new Mystery("NT21102021", 48, "Male", "Electrical");
            Mystery mystery3 = new Mystery("KZ18072013", 29, "Female", "Tourism");
            Regular regular  = new Regular("XM19111996", 23, "Male", "Marx");

            Shopper shopper;

            shopper = mystery1;
            Console.WriteLine(shopper.GetDisplayShopperInfo("\n"));
            Console.WriteLine();

            shopper = mystery2;
            Console.WriteLine(shopper.GetDisplayShopperInfo("\n"));
            Console.WriteLine();

            shopper = mystery3;
            Console.WriteLine(shopper.GetDisplayShopperInfo("\n"));

            Console.WriteLine();
            //shopper = regular;
            Console.WriteLine(regular.GetDisplayShopperInfo("\n"));

            Console.ReadKey();
        }
Esempio n. 7
0
        public ParcelManagerServiceResult <IEnumerable <Parcel> > Start(IEnumerable <Parcel> parcels)
        {
            var result = new List <Parcel>();

            //**** setting up the chain of responsibility pattern to solve to automate the internal handling of parcels coming in

            /* For Adding A New Department To Handle Some New Business Rules  First You Must Define It in Business Folder And Then You Must Put It in Below Chain
             * And If You Want This New Department Execute First You Must Put It In The First Of The Chain Like Insurance
             */
            RelatedHandler <Parcel> insuranceDepartment = new Insurance();           //insurance must be in the first of the chain because of its business
            RelatedHandler <Parcel> heavyDepartment     = new Heavy();
            RelatedHandler <Parcel> mailDepartment      = new Mail();
            RelatedHandler <Parcel> regularDepartment   = new Regular();

            insuranceDepartment
            .SetNext(heavyDepartment)
            .SetNext(mailDepartment)
            .SetNext(regularDepartment);



            //iterate over each parcel to process and then return the processed list
            foreach (Parcel parcel in parcels)
            {
                insuranceDepartment.Run(parcel);
            }

            return(new ParcelManagerServiceResult <IEnumerable <Parcel> >(result: parcels));
        }
Esempio n. 8
0
        /// <summary>
        /// 定义仓储
        /// </summary>
        /// <param name="connectionString">连接字符串或数据库KEY</param>
        /// <param name="providerName">数据库类型</param>
        /// <returns></returns>
        public SqlSugarClient GetInstance(string connectionString, string providerName)
        {
            if (!Regular.IsGuidByParse(connectionString))
            {
                return(new SqlSugarClient(new ConnectionConfig {
                    ConnectionString = connectionString, DbType = Types[providerName], IsAutoCloseConnection = true
                }));
            }
            var            entity = GetConnectionManage(connectionString);
            SqlSugarClient db;
            string         connectionStr;

            //判断当前主链接是否可用
            try
            {
                connectionStr = entity.PkConnection;
                db            = new SqlSugarClient(new ConnectionConfig {
                    ConnectionString = connectionStr, DbType = Types[entity.DBType], IsAutoCloseConnection = true
                });
                db.Ado.GetScalar("select 1+1");
                return(db);
            }
            catch (Exception)
            {
                //说明主服务器不可用
                connectionStr = entity.SpareConnection;
                db            = new SqlSugarClient(new ConnectionConfig {
                    ConnectionString = connectionStr, DbType = Types[entity.DBType], IsAutoCloseConnection = true
                });
                db.Ado.GetScalar("select 1+1");
                return(db);
            }
        }
Esempio n. 9
0
 //Opretter bruger alt efter hvilken type
 public void CreateUser()
 {
     if (UserVM.Type == "Admin")
     {
         Admin admin = new Admin(UserVM.ViewMaNr, UserVM.ViewNavn, UserVM.ViewTlf, UserVM.ViewAdresse, UserVM.ViewEmail, UserVM.ViewPassword);
         admin.AfdNavn = UserVM.Afdeling.Navn;
         admin.AfdId   = UserVM.Afdeling.AfdId.ToString();
         UserVM.UserCatalogSingleton.AddUser(admin);
         AddUserToAfdeling(admin);
     }
     else if (UserVM.Type == "Leader")
     {
         Leader leader = new Leader(UserVM.ViewMaNr, UserVM.ViewNavn, UserVM.ViewTlf, UserVM.ViewAdresse, UserVM.ViewEmail, UserVM.ViewPassword);
         leader.AfdNavn = UserVM.Afdeling.Navn;
         leader.AfdId   = UserVM.Afdeling.AfdId.ToString();
         UserVM.UserCatalogSingleton.AddUser(leader);
         AddUserToAfdeling(leader);
     }
     else if (UserVM.Type == "Regular")
     {
         Regular regular = new Regular(UserVM.ViewMaNr, UserVM.ViewNavn, UserVM.ViewTlf, UserVM.ViewAdresse, UserVM.ViewEmail, UserVM.ViewPassword);
         regular.AfdNavn = UserVM.Afdeling.Navn;
         regular.AfdId   = UserVM.Afdeling.AfdId.ToString();
         UserVM.UserCatalogSingleton.AddUser(regular);
         AddUserToAfdeling(regular);
     }
 }
Esempio n. 10
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            string text = "Мальчик проснулся в 11:50, а должен был проснуться в 09:00.";

            textBox1.Text += text;
            string pattern = ("[0-2][0-9]:[0-6][0-9]");

            textBox2.Text += pattern;
            Regular myReg = new Regular(pattern, text);

            if (myReg)
            {
                textBox3.Text += "Строка не пуста";
            }
            else
            {
                textBox3.Text += "Строка пуста";
            }
            textBox4.Text += myReg.ToString();
            Regular myReg2 = Regular.StringToRegular("[19:56] играю на аккордеоне");

            textBox5.Text += myReg2.ToString();
            textBox6.Text += myReg[0];
            textBox7.Text += myReg[1] + "\n\r";
            textBox7.Text += "\n\r" + "Другое значение индекса:" + "\n\r";
            textBox7.Text += myReg[6];
            textBox8.Text += myReg = myReg + "12345";
            textBox9.Text += myReg = -myReg;
        }
Esempio n. 11
0
        private void agregarTipoBomba()  // se crea private porque sera utilizada dentro de la clase
        {
            WriteTitle("Tipo de Bomba");
            WriteLine("1. Super");
            WriteLine("2. Regular");
            WriteLine("3. Diesel");
            WriteLine("0. Salir");
            WriteLine("Seleccione una opcion ==>");
            string respuesta = ReadLine();

            if (respuesta.Equals("1"))
            {
                Bomba super = new Super();
                AgregarElemento(super);
            }
            else if (respuesta.Equals("2"))
            {
                Bomba regular = new Regular();
                AgregarElemento(regular);
            }
            else if (respuesta.Equals("3"))
            {
                Bomba diesel = new Diesel();
                AgregarElemento(diesel);
            }
        }
Esempio n. 12
0
 public AllNoneGuy(string name, string job, int maxHealth, ETargetType targetType) : base(name, job, maxHealth, targetType)
 {
     for (int x = 0; x < 6; x++)
     {
         Abilities[x] = new Regular(new Bare());
     }
 }
Esempio n. 13
0
 public IActionResult Edit(Regular regular)
 {
     if (ModelState.IsValid)
     {
         _regularRepository.EditRegular(regular);
     }
     return(RedirectToAction(nameof(Index)));
 }
        public async Task <UpdateClientOutput> UpdateClient(UpdateClientInput input)
        {
            if (!Regular.IsMatchLettersNumbers(input.ClientId))
            {
                return(new UpdateClientOutput()
                {
                    ErrorMessage = "客户端Id只能输入数字和字母"
                });
            }

            if (!string.IsNullOrEmpty(input.ClientSecret) && !Regular.IsMatchLettersNumbers(input.ClientSecret))
            {
                return(new UpdateClientOutput()
                {
                    ErrorMessage = "密匙只能输入数字和字母"
                });
            }

            if (!string.IsNullOrEmpty(input.ClientSecret) && (input.ClientSecret.Length < 6 || input.ClientSecret.Length > 50))
            {
                return(new UpdateClientOutput()
                {
                    ErrorMessage = "客户端密匙长度必须大于或等于6,小于或等于50"
                });
            }

            Expression <Func <Client, object> >[] clientLoad = new Expression <Func <Client, object> >[] {
                e => e.AllowedGrantTypes,
                e => e.RedirectUris,
                e => e.PostLogoutRedirectUris,
                e => e.AllowedScopes,
            };

            var client = _clientManager.GetClientInclude(input.Id, clientLoad);

            _clientManager.UpdateAllowedGrantType(client, input.AllowedGrantType);
            _clientManager.UpdateAllowedScopes(client, input.AllowedScopes);
            _clientManager.UpdatePostLogoutRedirectUris(client, input.PostLogoutRedirectUris);
            _clientManager.UpdateRedirectUris(client, input.RedirectUris);

            // 如果密匙不为空,则更新
            if (!string.IsNullOrEmpty(input.ClientSecret))
            {
                _clientManager.UpdateSecrets(client, new List <string>()
                {
                    input.ClientSecret
                });
            }

            client.ClientId   = input.ClientId;
            client.ClientName = input.ClientName;
            client.AllowAccessTokensViaBrowser = input.AllowAccessTokensViaBrowser;
            client.AllowOfflineAccess          = input.AllowOfflineAccess;
            client.Enabled         = input.Enabled;
            client.AccessTokenType = (int)("jwt".Equals(input.AccessTokenType, StringComparison.OrdinalIgnoreCase) ? IdentityServer4.Models.AccessTokenType.Jwt : IdentityServer4.Models.AccessTokenType.Reference);

            return(new UpdateClientOutput());
        }
Esempio n. 15
0
        public void ShouldSetValueInInstance()
        {
            Regular      regular = new Regular();
            PropertyInfo info    = typeof(Regular).GetProperty("Value");
            ReflectorProperty <Regular, string> property = new ReflectorProperty <Regular, string>(info);

            property.SetValue(regular, "cde");
            Assert.That(regular.Value, Is.EqualTo("cde"));
        }
Esempio n. 16
0
 public GoblinSorcerer(string name, string job, int maxHealth, ETargetType targetType) : base(name, job, maxHealth, targetType)
 {
     Abilities[0] = new Vulnerable(new Bare("Head", "Your bare head"));
     Abilities[1] = new Regular(new IceBeam());
     Abilities[2] = new Regular(new LightningBolt());
     Abilities[3] = new Evade(new Spring(), 0.25f);
     Abilities[4] = new Vulnerable(new Bare("Chest", "Your bare chest"));
     Abilities[5] = new Vulnerable(new Bare("Back", "Your bare back"));
 }
Esempio n. 17
0
        public ActionResult Registrarse(FormCollection form)
        {
            Usuario user    = new Usuario();
            Regular regular = new Regular();

            var name        = form["nombre"];
            var lastName    = form["apellidos"];
            var bankAccount = form["numeroCuenta"];

            var email       = form["correoElectronico"];
            var pass        = form["contraseña"];
            var passConfirm = form["confirmarContraseña"];

            if (string.Compare(pass, passConfirm) == 0)
            {
                user.correo     = email;
                user.contrasena = Crypto.Hash(pass);

                user.contrasena = user.contrasena;

                user.idRolUsuario = 3;          // 3 = regular

                regular.primerNombre   = name;
                regular.apellidos      = lastName;
                regular.cuentaBancaria = Convert.ToDecimal(bankAccount);
                neo.agregarUsuario(user);

                if (ModelState.IsValid)
                {
                    if (emailExist(email))
                    {
                        ViewBag.Error = "El correo ya esta registrado en el sistema.";
                    }
                    else
                    {
                        using (serviciosCREntities db = new serviciosCREntities())
                        {
                            db.Usuarios.Add(user);
                            db.SaveChanges();
                            var v = db.Usuarios.Where(a => a.correo == user.correo).FirstOrDefault();
                            regular.idUsuario = v.idUsuario;
                            db.Regulars.Add(regular);
                            db.SaveChanges();
                            ViewBag.Error = "Usuario creado correctamente";

                            return(RedirectToAction("InicioSesion", "Cliente"));
                        }
                    }
                }
            }
            else
            {
                ViewBag.Error = "Contraseñas no coiciden";
            }
            return(PartialView(form));
        }
Esempio n. 18
0
 public Sorcerer(string name, int maxHealth, ETargetType targetType)
     : base(name, "Sorcerer", maxHealth, targetType)
 {
     Abilities[0] = new Regular(new DragonsBreath());
     Abilities[1] = new Regular(new IceBeam());
     Abilities[2] = new Regular(new LightningBolt());
     Abilities[3] = new Evade(new Spring(), 0.25f);
     Abilities[4] = new Vulnerable(new Bare("Chest", "Your bare chest"));
     Abilities[5] = new Vulnerable(new Bare("Back", "Your bare back"));
 }
Esempio n. 19
0
 public Warrior(string name, int maxHealth, ETargetType targetType)
     : base(name, "Warrior", maxHealth, targetType)
 {
     Abilities[0] = new Regular(new Headbutt());
     Abilities[1] = new Armored(new Shieldslam(), 3);
     Abilities[2] = new Regular(new Slash());
     Abilities[3] = new Regular(new Kick());
     Abilities[4] = new Regular(new Tackle());
     Abilities[5] = new Vulnerable(new Bare("Back", "Your bare back"));
 }
Esempio n. 20
0
 public Cleric(string name, int maxHealth, ETargetType targetType)
     : base(name, "Cleric", maxHealth, targetType)
 {
     Abilities[0] = new Regular(new Prayer());
     Abilities[1] = new Armored(new Shieldslam(), 3);
     Abilities[2] = new Regular(new Heal());
     Abilities[3] = new Evade(new Dodge(), 0.25f);
     Abilities[4] = new Armored(new Bare("Chest", "Bare Chest"), 3);
     Abilities[5] = new Vulnerable(new Bare("Back", "Your bare back"));
 }
Esempio n. 21
0
        public void ShouldFindNullInNullableString()
        {
            Regular regular = new Regular {
                Value = null
            };
            PropertyInfo info = typeof(Regular).GetProperty("Value");
            ReflectorProperty <Regular, string> property = new ReflectorProperty <Regular, string>(info);

            Assert.That(property.IsNull(regular), Is.True);
        }
        public void TestSpecializedEquipmentRentalMoreThanTwoDays()
        {
            RentalCalculator rc = new RentalCalculator();
            Regular          r  = new Regular();
            Premium          pr = new Premium();
            int   days          = 5;
            float shouldBe      = pr.getFees(3) + r.getFees(2);

            Assert.AreEqual(rc.getRentalPrice(EquipmentType.Specialized, days), shouldBe);
        }
Esempio n. 23
0
        public void ShouldGetValue()
        {
            Regular regular = new Regular {
                Value = "abc"
            };
            PropertyInfo info = typeof(Regular).GetProperty("Value");
            ReflectorProperty <Regular, string> property = new ReflectorProperty <Regular, string>(info);

            Assert.That(property.GetValue(regular), Is.EqualTo("abc"));
        }
Esempio n. 24
0
        public void AddProducao(Regular p)
        {
            AddSimbolo(p.Atual);

            foreach (var s in p.Proximos)
            {
                AddSimbolo(s);
            }

            Producoes.Add(p);
        }
Esempio n. 25
0
        public void ShouldSetNullInNullableStringInInstance()
        {
            Regular regular = new Regular {
                Value = "abc"
            };
            PropertyInfo info = typeof(Regular).GetProperty("Value");
            ReflectorProperty <Regular, string> property = new ReflectorProperty <Regular, string>(info);

            property.SetNull(regular);
            Assert.That(regular.Value, Is.Null);
        }
        public void TestRegularEquipmentRentalMoreThanTwoDays()
        {
            RentalCalculator rc = new RentalCalculator();
            OneTime          ot = new OneTime();
            Premium          pr = new Premium();
            Regular          r  = new Regular();
            int   days          = 3;
            float shouldBe      = ot.getFees() + pr.getFees(2) + r.getFees(1);

            Assert.AreEqual(rc.getRentalPrice(EquipmentType.Regular, days), shouldBe);
        }
Esempio n. 27
0
        public void ShouldHandleCastedSetConversionInInstance()
        {
            Regular      regular = new Regular();
            PropertyInfo info    = typeof(Regular).GetProperty("Value");

            ReflectorProperty <Regular, string> property = new ReflectorProperty <Regular, string>(info);
            ReflectorProperty <Regular, string> casted   = property.Cast(x => x.ToLower(), x => x.ToUpper());

            casted.SetValue(regular, "cDe");
            Assert.That(regular.Value, Is.EqualTo("CDE"));
        }
Esempio n. 28
0
        public void CalculatePrice_WithMoreThenTwoDays()
        {
            Regular regular = new Regular();

            float result = regular.CalculatePrice(3);

            Assert.AreEqual(320, result);

            result = regular.CalculatePrice(15);

            Assert.AreEqual(1520, result);
        }
Esempio n. 29
0
        public void ShouldHandleCastedGetConversion()
        {
            Regular item = new Regular {
                Value = "aBc"
            };
            PropertyInfo info = typeof(Regular).GetProperty("Value");

            ReflectorProperty <Regular, string> property = new ReflectorProperty <Regular, string>(info);
            ReflectorProperty <Regular, string> casted   = property.Cast(x => x.ToLower(), x => x.ToUpper());

            Assert.That(casted.GetValue(item), Is.EqualTo("abc"));
        }
Esempio n. 30
0
        public void CalculatePrice_WithDaysLessThenZero()
        {
            Regular regular = new Regular();

            float result = regular.CalculatePrice(0);

            Assert.AreEqual(0, result);

            result = regular.CalculatePrice(-3212);

            Assert.AreEqual(0, result);
        }
Esempio n. 31
0
        static void Main(string[] args)
        {
            var suzuki = new Regular() { Name = "Suzuki", Age = 40 };
            var yamada = new PartTimer() { Name = "Yamada", Age = 30, EmploymentPeriod = DateTime.Now };
            var tanaka = new Regular() { Name = "Tanaka", Age = 20 };

            var yucho = new Company() { Name = "Yucho" };
            yucho.Employ(suzuki);
            yucho.Employ(yamada);

            var kanpo = new Company() { Name = "Kampo" };
            kanpo.Employ(yamada);
            kanpo.Employ(tanaka);

            var yuseiGroup = new CompanyGroup();
            yuseiGroup.Companys.Add(yucho);
            yuseiGroup.Companys.Add(kanpo);

            var settings = new JsonSerializerSettings()
            {
                Formatting = Formatting.Indented,
                TypeNameHandling = TypeNameHandling.Auto,
            };

            var json = JsonConvert.SerializeObject(yuseiGroup, settings);
            Console.WriteLine(json);

            var deserialized = JsonConvert.DeserializeObject<CompanyGroup>(json, settings);

            Company company;

            company = deserialized.Companys.FirstOrDefault(x => x.Name == "Yucho");
            if (company != null)
            {
                foreach (var e in company.Employments)
                {
                    e.Age++;
                    Print(e);
                }
            }

            company = deserialized.Companys.FirstOrDefault(x => x.Name == "Kampo");
            if (company != null)
            {
                foreach (var e in company.Employments)
                {
                    e.Age++;
                    Print(e);
                }
            }
        }