private void btAdd_Click(object sender, EventArgs e)
        {
            try
            {
                if ((tbUnitsСommodity.Text != "kg") && (tbUnitsСommodity.Text != "l") && (tbUnitsСommodity.Text != "g"))
                {
                    throw new Exception();
                }

                Industrial industrial = new Industrial(tbSize.Text, tbMaterial.Text, tbColor.Text, tbNameGoods.Text, Convert.ToDouble(tbCostСommodity.Text),
                                                       tbUnitsСommodity.Text, tbGenerator.Text, tbShelfLife.Text);
                Commodity._commodities.Add(industrial);

                Refresh_Goods();

                Clear_Industrial();
                Clear_Commodity();
            }
            catch (Exception)
            {
                MessageBox.Show("Error: invalid input value");

                tbCostСommodity.Clear();
                tbUnitsСommodity.Clear();
            }
        }
        //Below event of clicking Add Customer button adds customer in the list, calculates total bill amt of customer by their type, count total # of customer and calculate total bill of all customers in list
        private void btnAddCustomer_Click(object sender, EventArgs e)
        {
            Customer c = null;

            if (Validator.IsProvided(txtCustName, "Customer Name") && Validator.IsProvided(txtCustName, "Account Number") && Validator.IsNonNegativeInt(txtAccountNo, "Account Number") && Validator.IsUnique(txtAccountNo, "Account#", lstCustomers))
            {
                if (rdResidential.Checked)
                {
                    c = new Residential(txtCustName.Text, Convert.ToInt32(txtAccountNo.Text), 'R'); //creating Residential customer object
                    c.CustomerCharge = c.calculateBill(int.Parse(txtKwh.Text));                     //Calculatinga a bill amt of  Residential customer
                    res += c.CustomerCharge;                                                        //Adding new bill charge of residential customer to the existing bill amount of Residential customers
                    txtResidentialType.Text = res.ToString("c");
                }
                if (rdCommercial.Checked)
                {
                    c = new Commercial(txtCustName.Text, Convert.ToInt32(txtAccountNo.Text), 'C'); // creating Commercial customer object
                    c.CustomerCharge = c.calculateBill(int.Parse(txtKwh.Text));                    //Calculatinga a bill amt of Commercial customer
                    com += c.CustomerCharge;                                                       //Adding new bill charge of Commercial customer to the existing bill amount of Commercial customers
                    txtCommercialType.Text = com.ToString("c");
                }
                if (rdIndustrial.Checked)
                {
                    c = new Industrial(txtCustName.Text, Convert.ToInt32(txtAccountNo.Text), 'I');               // creating Industrial customer object
                    c.CustomerCharge = c.calculateBill(int.Parse(txtOnPeak.Text), (int.Parse(txtOffPeak.Text))); //Calculating a bill amt of Industrial customer
                    ind += c.CustomerCharge;                                                                     //Adding new bill charge of industrial customer to the existing bill amount of industrial customers
                    txtIndutrialType.Text = ind.ToString("c");
                }
                customerList.Add(c);
                DisplayCustomers();
            }
        }
示例#3
0
 public LaterGrowth()
 {
     city            = GameObject.Find("City").GetComponent <City>();
     industrial      = new Industrial();
     commercial      = new Commercial();
     residential     = new Residential();
     blockHelper     = new BlockHelper(city, industrial, commercial, residential);
     maxDist         = 0.1f;
     minStreetLength = 9f;
     maxStreetLength = 15f;
 }
示例#4
0
        private void createDevices()
        {
            //Console.WriteLine("Creating Device Objects...");
            List <Device> new_devices = new List <Device>();

            foreach (var dev in _devices)
            {
                switch (dev.module_type)
                {
                case 0:     //unknown
                    break;

                case 1:     // *** Smartplug ***
                    SmartPlug smartplug = new SmartPlug(dev);
                    new_devices.Add(smartplug);
                    break;

                case 2:     // *** Bluetooth ***
                    Bluetooth bluetooth = new Bluetooth(dev);
                    new_devices.Add(bluetooth);
                    break;

                case 3:     // *** USB ***
                    USB usb = new USB(dev);
                    new_devices.Add(usb);
                    break;

                case 4:     // *** Infrared ***
                    Infrared infrared = new Infrared(dev);
                    new_devices.Add(infrared);
                    break;

                case 5:     // *** Industrial ***
                    Industrial industrial = new Industrial(dev);
                    new_devices.Add(industrial);
                    break;

                case 6:     // *** Multiboard ***
                    Multiboard multiboard = new Multiboard(dev);
                    new_devices.Add(multiboard);
                    break;

                case 7:     // *** Audio ***
                    Audio audio = new Audio(dev);
                    new_devices.Add(audio);
                    break;

                default:
                    break;
                }
            }
            _devices.Clear();
            _devices.AddRange(new_devices);
        }
示例#5
0
        // This test should be redundant since the validation in the input feilds and at the class level make it HIGHLY unlikely
        // a negative value will ever be passed into the calculation
        public void CalculateRateIndustrialNegativeHoursTest()
        {
            // Arrange
            Industrial client = new Industrial(); // create a new client object
            decimal    returnAmt;                 // holds the return from CaclulateRate()
            decimal    expectedAmt = 116.00m;     // $6 is the base rate a Residential customer will pay regardless of usage

            client.PeakHours    = -100;           // set the usage hours to -100, validation should set it to 0
            client.OffPeakHours = -100;
            // Act
            returnAmt = client.CalculateRate();

            // Assert
            Assert.AreEqual(expectedAmt, returnAmt);
        }
示例#6
0
        public void CalculateRateIndustrialBelowBaseHoursTest()
        {
            // Arrange
            Industrial client = new Industrial(); // create a new client object
            decimal    returnAmt;                 // holds the return from CaclulateRate()
            decimal    expectedAmt = 116.00m;     // $116 is the base rate an Industrial customer will pay for usage under 1000hrs for both Peak and Off Peak

            client.PeakHours    = 900;            // set the usage hours to 900
            client.OffPeakHours = 900;

            // Act
            returnAmt = client.CalculateRate();

            // Assert
            Assert.AreEqual(expectedAmt, returnAmt);
        }
示例#7
0
        public void IndustrialBill()  //Testing if usage >1000 kwh for Industrial customer for both onpeak and offpeak hours
        {
            //arrange
            int        onPeak       = 2000;
            int        offPeak      = 1500;
            double     expectedbill = 195;
            double     actualBill;
            Industrial i; //ref of Industrial class

            //act
            i          = new Industrial("Birju", 123, 'I');
            actualBill = i.calculateBill(onPeak, offPeak);  //calling the method to calculate bill for indutrial customer to test actual bill against expected bill

            //assert
            Assert.AreEqual(actualBill, expectedbill);
        }
示例#8
0
        public void CalculateRateIndustrialAboveBaseHoursTest2()
        {
            // Arrange
            Industrial client = new Industrial(); // create a new client object
            decimal    returnAmt;                 // holds the return from CaclulateRate()
            decimal    expectedAmt = 265.00m;     // $116 is the base rate for Industrial customer will pay for usage under 1000hrs for both Peak and Off Peak

            //plus $65 for 1000 over @ $0.065/hr (Peak) and $84 for 3000 over @ $0.028/hr (Off Peak)
            client.PeakHours    = 2000; // set the usage hours to 2000
            client.OffPeakHours = 4000; // setting the OP hours to a differnet amount

            // Act
            returnAmt = client.CalculateRate();

            // Assert
            Assert.AreEqual(expectedAmt, returnAmt);
        }
示例#9
0
 private void Form1_Load(object sender, EventArgs e)
 {
     lblWelcome.Show();
     lblOption.Hide();
     Residential.Hide();
     Commercial.Hide();
     Industrial.Hide();
     PeakHours.Hide();
     OffPeak.Hide();
     lblEnter.Hide();
     txtInput.Hide();
     btnCalculate.Hide();
     btnClear.Hide();
     Output.Hide();
     Choose.Show();
     btnExit.Hide();
 }
示例#10
0
        // Instantiate a new building
        public static void createBuilding(BuildingClass type_of_building)
        {
            int[] building_data = BuildingsHelper.pickBuilding(type_of_building);

            // Residential
            if (type_of_building == BuildingClass.Residential)
            {
                prefab       = Resources.Load(BuildingUtils.getResidentialPath(building_data[1])) as GameObject;
                building_obj = GameObject.Instantiate(prefab) as GameObject;

                new_building = Residential.CreateComponent(building_obj,
                                                           (ResidentialType)building_data[0],
                                                           (ResidentialSize)building_data[1],
                                                           (ResidentialVariation)building_data[2]);
            }

            // Commercial
            else if (type_of_building == BuildingClass.Commercial)
            {
                prefab       = Resources.Load(BuildingUtils.getCommercialPath(building_data[1])) as GameObject;
                building_obj = GameObject.Instantiate(prefab) as GameObject;

                new_building = Commercial.CreateComponent(building_obj,
                                                          (CommercialType)building_data[0],
                                                          (CommercialSize)building_data[1],
                                                          (CommercialVariation)building_data[2]);
            }

            // Industrial
            else if (type_of_building == BuildingClass.Industrial)
            {
                prefab       = Resources.Load(BuildingUtils.getIndustrialPath(building_data[1])) as GameObject;
                building_obj = GameObject.Instantiate(prefab) as GameObject;

                new_building = Industrial.CreateComponent(building_obj,
                                                          (IndustrialType)building_data[0],
                                                          (IndustrialSize)building_data[1],
                                                          (IndustrialVariation)building_data[2]);
            }
            else
            {
                throw new NoSuchTypeException("Building Type not found");
            }
        }
示例#11
0
        public void TestCalculateChargeOverFlat()
        {
            // Arrange
            Client  person; //declare reference variable
            string  name           = "Fred";
            int     acctNo         = 1;
            string  type           = "r";
            decimal kwh            = 1500;
            decimal expectedCharge = 108.50m;
            decimal actualCharge;

            //Act
            person       = new Industrial(name, acctNo, type); // create account with initial balance
            actualCharge = person.CalculateBill(kwh);


            //Assert
            Assert.AreEqual(expectedCharge, actualCharge);
        }
        private void btnCalculate_Click(object sender, EventArgs e)
        {
            //Residential Customer energy bill Calculation when residental customer radio button is selected
            if (rdResidential.Checked == true)
            {
                if (Validator.IsProvided(txtKwh, "Energy Usage") && Validator.IsNonNegativeInt(txtKwh, "Energy usage") && Validator.IsNonNegativeDbl(txtKwh, "usage"))
                {
                    Customer c            = new Residential(null, 0, '0'); //passing null and 0 in the constructors as  we don't want to save the object in the list yet
                    int      input        = Convert.ToInt32(txtKwh.Text);  //converting user input into integer
                    double   restotalBill = c.calculateBill(input);        //calling the function which calculates residential bill
                    txtChargeAmt.Text = restotalBill.ToString("c");        //displaying result with $ currancy
                }
            }
            //Commercial customer energy bill calculation when commercial customer radio button is selected
            if (rdCommercial.Checked == true)
            {
                if (Validator.IsProvided(txtKwh, "Energy Usage") && Validator.IsNonNegativeInt(txtKwh, "Energy usage") && Validator.IsNonNegativeDbl(txtKwh, "usage"))
                {
                    Customer c            = new Commercial(null, 0, '0'); //passing null and 0 in the constructors as  we don't want to save the object in the list yet
                    int      input        = Convert.ToInt32(txtKwh.Text); //converting user input into integer
                    double   comtotalBill = c.calculateBill(input);       //calling the function which calculates commercial bill
                    txtChargeAmt.Text = comtotalBill.ToString("c");       //displaying result with $ currancy
                }
            }


            //Industrial  customer energy bill calculation when indutrial customer radio button is selected
            if (rdIndustrial.Checked == true)
            {
                if (Validator.IsProvided(txtOnPeak, "Energy Usage") && Validator.IsNonNegativeInt(txtOnPeak, "Energy usage") && Validator.IsNonNegativeDbl(txtOnPeak, "Energy usage") &&
                    Validator.IsProvided(txtOffPeak, "Energy Usage") && Validator.IsNonNegativeInt(txtOffPeak, "Energy usage") && Validator.IsNonNegativeDbl(txtOffPeak, "Energy usage"))

                {
                    Customer c            = new Industrial(null, 0, '0');     //passing null and 0 in the constructors as  we don't want to save the object in the list yet
                    int      onpeak       = Convert.ToInt32(txtOnPeak.Text);  //converting user input into integer
                    int      offpeak      = Convert.ToInt32(txtOffPeak.Text); //converting user input into integer
                    double   indTotalBill = c.calculateBill(onpeak, offpeak); //calling the function which calculates industrial bill
                    txtChargeAmt.Text = indTotalBill.ToString("c");           //displaying result with $ currancy
                }
            }
        }
示例#13
0
        static void Main(string[] args)
        {
            var jericho = new Snake("Jericho", "Boa Constrictor");

            jericho.FeedReptile();
            jericho.Speak();
            jericho.Slither();

            var rogue = new Iguana("Rogue", "Green Iguana");

            rogue.FeedReptile();
            rogue.Speak();
            rogue.Dislike();

            var snuggles = new Alligator("Snuggles", "American Alligator");

            snuggles.FeedReptile();
            snuggles.Speak();
            snuggles.DeathRoll();

            var fgfc820 = new Industrial("FGFC820", "Aggrotech")
            {
                AlbumNumber = 10
            };

            fgfc820.RockOut("Bridgestone Arena");
            fgfc820.CheckAlbums();
            fgfc820.Bringit();

            var vnvNation = new Industrial("VNV Nation", "EBM")
            {
                AlbumNumber = 20
            };

            vnvNation.RockOut("Exit/In");
            vnvNation.CheckAlbums();
            vnvNation.Bringit();

            var bach = new Classical("Johan Sebestian Bach", "Baroque");

            bach.Encore();

            var theGrapesOfWrath = new Novel("The Grapes of Wrath", 525, "John Steinbeck")
            {
                HaveRead = true
            };

            theGrapesOfWrath.Open();
            theGrapesOfWrath.Read();

            var braveNewWorld = new Novel("Brave New World", 452, "Aldous Huxley")
            {
                HaveRead = false
            };

            braveNewWorld.Read();

            var verdi = new PictureBook("Verdi", 15, "Janell Cannon");

            verdi.Read();

            var worldOfWarcraft = new VideoGames("World of Warcraft", new DateTime(2004, 11, 24))
            {
                Developer = "Blizzard",
                GameGenre = GameGenre.MMO
            };

            worldOfWarcraft.Play();
            worldOfWarcraft.Return();

            var doom = new VideoGames("Doom", new DateTime(1993, 12, 10))
            {
                Developer = "id Software",
                GameGenre = GameGenre.Shooter
            };

            doom.Play();
            doom.Return();

            Console.ReadKey();
        }
示例#14
0
    public void ReevaluateLUT()
    {
        List <Block> candidates = new List <Block>();

        int numCandidates = Math.Min((int)((double)city.blocks.Count * 0.1), 10);

        while (candidates.Count != numCandidates)
        {//get candidates
            int index = UnityEngine.Random.Range(0, city.blocks.Count - 1);
            if (!candidates.Contains(city.blocks[index]) && city.blocks[index].lut.getName() != "core")
            {
                candidates.Add(city.blocks[index]);
            }
        }

        for (int j = 0; j < candidates.Count; j++)
        {
            //find land use values for each lut
            float i = CalculateLUV("industrial", candidates[j]);
            float c = CalculateLUV("commercial", candidates[j]);
            float r = CalculateLUV("residential", candidates[j]);

            float       newLUV = Math.Max(Math.Max(i, c), r);
            LandUseType newLUT;

            if (newLUV == i)
            {
                newLUT = new Industrial();
            }
            else if (newLUV == c)
            {
                newLUT = new Commercial();
            }
            else
            {
                newLUT = new Residential();
            }


            if (candidates[j].lut.getName() != newLUT.getName())
            { // better land use type found
                float currentLUV = 0f;

                switch (candidates[j].lut.getName())
                {
                case "industrial":
                    currentLUV = i;
                    break;

                case "commercial":
                    currentLUV = c;
                    break;

                default:
                    currentLUV = r;
                    break;
                }

                float diff = newLUV - currentLUV;

                //calculate cost of replacement
                float cost = 0.7f - diff;

                if (candidates[j].building.size == 1)
                {
                    cost += 0.1f;
                }
                else if (candidates[j].building.size == 2)
                {
                    cost += 0.2f;
                }
                else
                {
                    cost += 0.3f;
                }

                var random = UnityEngine.Random.Range(0, 100);
                if (random > cost * 100)
                {
                    //replace lut
                    ReplaceLUT(candidates[j], newLUT);
                    changedBlocks.Add(candidates[j]);
                }
            }
        }
    }
 public ActionResult Industrial(Industrial model)
 {
示例#16
0
 public IndustrialLarge(Industrial ind_device)
 {
     InitializeComponent();
     _device = ind_device;
 }
示例#17
0
 public IndustrialSmall(Industrial ind_device)
 {
     InitializeComponent();
     _device = ind_device;
 }