示例#1
0
        private void createObjectButton_Click(object sender, EventArgs e)
        {
            Cellphone myPhone = new Cellphone();

            GetPhoneData(myPhone);

            brandLabel.Text = myPhone.Brand;
            modelLabel.Text = myPhone.Model;
            priceLabel.Text = myPhone.Price.ToString("c");
        }
示例#2
0
        private void createObjectButton_Click(object sender, EventArgs e)
        {
            Cellphone myPhone = new Cellphone();

            GetPhoneData(myPhone);

            brandLabel.Text = myPhone.Brand;
            modelLabel.Text = myPhone.Model;
            priceLabel.Text = myPhone.Price.ToString("c");
        }
示例#3
0
        //The GetPhonedata method accepts a CellPhone object as an argument. It assigns the data enetered by the
        //user to the object's property.
        private void GetPhoneData(Cellphone phone)
        {
            //Temporary Variable to hold the price
            decimal price;

            //Get the phone's brand.
            phone.Brand = brandTextBox.Text;

            //Get the phone's model
            phone.Model = modelTextBox.Text;

            //Get the phone's price
            if (decimal.TryParse(priceTextBox.Text, out price))
            {
                phone.Price = price;
            }
            else
            {
                MessageBox.Show("Invalid Price");
            }
        }
示例#4
0
        //The GetPhonedata method accepts a CellPhone object as an argument. It assigns the data enetered by the
        //user to the object's property.
        private void GetPhoneData(Cellphone phone)
        {
            //Temporary Variable to hold the price
            decimal price;

            //Get the phone's brand.
            phone.Brand = brandTextBox.Text;

            //Get the phone's model
            phone.Model = modelTextBox.Text;

            //Get the phone's price
            if (decimal.TryParse(priceTextBox.Text, out price))
            {
                phone.Price = price;
            }
            else
            {
                MessageBox.Show("Invalid Price");
            }
        }