示例#1
0
        public void loadPrices()
        {
            double price;

            reader = File.OpenText("roof_prices.txt");
            price  = Convert.ToDouble(reader.ReadLine());
            part   = Roof.createInstance(price);
            reader.Close();
            reader = File.OpenText("foundation_prices.txt");
            price  = Convert.ToDouble(reader.ReadLine());
            part   = Foundation.createInstance(price);
            reader.Close();
            reader = File.OpenText("siding_prices.txt");
            price  = Convert.ToDouble(reader.ReadLine());
            part   = Siding.createInstance(price);
            reader.Close();
            reader = File.OpenText("door_prices.txt");
            price  = Convert.ToDouble(reader.ReadLine());
            part   = Door.createInstance(price);
            reader.Close();
            reader = File.OpenText("window_prices.txt");
            price  = Convert.ToDouble(reader.ReadLine());
            part   = Window.createInstance(price);
            reader.Close();
            reader = File.OpenText("paint_prices.txt");
            price  = Convert.ToDouble(reader.ReadLine());
            part   = PaintHASS.createInstance(Color.White, price);
            reader.Close();
            reader = File.OpenText("oceanside.txt");
            price  = Convert.ToDouble(reader.ReadLine());
            loc    = Oceanside.createInstance(price);
            reader.Close();
            reader = File.OpenText("city.txt");
            price  = Convert.ToDouble(reader.ReadLine());
            loc    = City.createInstance(price);
            reader.Close();
            reader = File.OpenText("desert.txt");
            price  = Convert.ToDouble(reader.ReadLine());
            loc    = Desert.createInstance(price);
            reader.Close();
            reader = File.OpenText("private_island.txt");
            price  = Convert.ToDouble(reader.ReadLine());
            loc    = PrivateIsland.createInstance(price);
            reader.Close();
            reader = File.OpenText("country.txt");
            price  = Convert.ToDouble(reader.ReadLine());
            loc    = Country.createInstance(price);
            reader.Close();
            reader = File.OpenText("suburb.txt");
            price  = Convert.ToDouble(reader.ReadLine());
            loc    = Suburb.createInstance(price);
            reader.Close();
        }
 public static Oceanside createInstance(double price)
 {
     if (o != null)
     {
         return(o);
     }
     else
     {
         o = new Oceanside(price);
         return(o);
     }
 }
        public void loadPrices()
        {
            double price;

            reader               = File.OpenText("roof_prices.txt");
            price                = Convert.ToDouble(reader.ReadLine());
            part                 = Roof.createInstance(price);
            roofLabel.Text       = part.getPrice().ToString();
            reader               = File.OpenText("foundation_prices.txt");
            price                = Convert.ToDouble(reader.ReadLine());
            part                 = Foundation.createInstance(price);
            foundationLabel.Text = price.ToString();
            reader               = File.OpenText("siding_prices.txt");
            price                = Convert.ToDouble(reader.ReadLine());
            part                 = Siding.createInstance(price);
            sidingLabel.Text     = price.ToString();
            reader               = File.OpenText("door_prices.txt");
            price                = Convert.ToDouble(reader.ReadLine());
            part                 = Door.createInstance(price);
            doorLabel.Text       = price.ToString();
            reader               = File.OpenText("window_prices.txt");
            price                = Convert.ToDouble(reader.ReadLine());
            part                 = Window.createInstance(price);
            windowLabel.Text     = price.ToString();
            reader               = File.OpenText("floor_prices.txt");
            price                = Convert.ToDouble(reader.ReadLine());
            part                 = Floor.createInstance(price);
            floorLabel.Text      = price.ToString();
            reader               = File.OpenText("paint_prices.txt");
            price                = Convert.ToDouble(reader.ReadLine());
            part                 = PaintHASS.createInstance(c, price);
            label8.Text          = price.ToString();
            reader               = File.OpenText("oceanside.txt");
            price                = Convert.ToDouble(reader.ReadLine());
            loc    = Oceanside.createInstance(price);
            reader = File.OpenText("city.txt");
            price  = Convert.ToDouble(reader.ReadLine());
            loc    = City.createInstance(price);
            reader = File.OpenText("desert.txt");
            price  = Convert.ToDouble(reader.ReadLine());
            loc    = Desert.createInstance(price);
            reader = File.OpenText("private_island.txt");
            price  = Convert.ToDouble(reader.ReadLine());
            loc    = PrivateIsland.createInstance(price);
            reader = File.OpenText("country.txt");
            price  = Convert.ToDouble(reader.ReadLine());
            loc    = Country.createInstance(price);
            reader = File.OpenText("suburb.txt");
            price  = Convert.ToDouble(reader.ReadLine());
            loc    = Suburb.createInstance(price);
        }
示例#4
0
        private void button3_Click(object sender, EventArgs e)
        {
            string text = textBox1.Text;

            if (textBox1.Text == "Oceanside")
            {
                loc = Oceanside.createInstance();
                loc = f.getLocation(text, loc.getPrice());
            }
            else if (textBox1.Text == "Country")
            {
                loc = Country.createInstance();
                loc = f.getLocation(text, loc.getPrice());
            }
            else if (textBox1.Text == "City")
            {
                loc = City.createInstance();
                loc = f.getLocation(text, loc.getPrice());
            }
            else if (textBox1.Text == "Private Island")
            {
                loc = PrivateIsland.createInstance();
                loc = f.getLocation(text, loc.getPrice());
            }
            else if (textBox1.Text == "Desert")
            {
                loc = Desert.createInstance();
                loc = f.getLocation(text, loc.getPrice());
            }
            else if (textBox1.Text == "Suburb")
            {
                loc = Suburb.createInstance();
                loc = f.getLocation(text, loc.getPrice());
            }
            else
            {
                loc = f.getLocation(text, 0);
            }
            //loc = f.getLocation(text, .getPrice());
            label13.Text = text;
            label14.Text = loc.getPrice().ToString();
        }