Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For reference, this is Programming Problem Ch 10, #4 in Starting Out with Visual C# 2012 by Tony Gaddis. The problem states Design a class

For reference, this is Programming Problem Ch 10, #4 in Starting Out with Visual C# 2012 by Tony Gaddis.

The problem states "Design a class named Person with properties for holding a person's name, address, and telephone number. Next, design a class named Customer, which is derived from the Person class. The Customer class should have a property for a customer number and a Boolean property indicating whether a customer wishes to be on a mailing list. Demonstrate an object of the customer class in a simple application."

Currently, I've created seperate .cs pages for the Person Class and Customer Class. Also, I've created some code for Form.cs and will include how it displays. In the Form1 code, I'm not sure how to use the boolean mailing property, so in the current form1 code it is not used.

Also, I'm not sure how to turn the customer number output to display as a int. currently, the number that I enter will display. I'm really not sure if that is what is supposed to be done with this assignment.

Currently this is what displays:

image text in transcribed

When text is entered:

image text in transcribed

My code is as follows:

Customer.cs ("public string customerNumber" should be "public int customerNumber" but I couldn't get it to work with the Form's code)

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;

namespace HW11CH10_4 { class Customer : Person { string _customerNumber; bool _mailing;

//customerNum property public string customerNumber { get { return _customerNumber; } set { _customerNumber = value; } }

//mailing property public bool Mailing { get { return _mailing; } set { _mailing = value; }

}

} }

Person.cs

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;

namespace HW11CH10_4 { class Person { string _name; string _address; string _phoneNumber;

/ame property public string Name { get { return _name; } set { _name = value; } }

//address property public string Address { get { return _address; } set { _address = value; } }

public string phoneNumber { get { return _phoneNumber; } set { _phoneNumber = value; } } } }

Form1.cs

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;

namespace HW11CH10_4 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { //object create for customer class Customer objcustomer = new Customer();

//set properties for customer class SetCustomerData(objcustomer);

//display customer properties label6.Text = objcustomer.Name; label7.Text = objcustomer.Address; label8.Text = objcustomer.phoneNumber; label9.Text = objcustomer.customerNumber.ToString();

}

private void SetCustomerData(Customer objcustomer) { //checks if name empty if (textBox1.Text != "") { //assigns object to text objcustomer.Name = textBox1.Text; } else { MessageBox.Show("Please Enter Customer Name"); }

//checks if address is empty if (textBox2.Text != "") { //assigns object to text objcustomer.Address = textBox2.Text; } else { MessageBox.Show("Please Enter Customer Address"); }

//checks if phone number is input if (textBox3.Text != "") { //assigns object to text objcustomer.phoneNumber = textBox3.Text; } else { MessageBox.Show("Please Enter Customer Phone Number"); }

//checks if cust number is input if (textBox4.Text != "") { //assigns object to text objcustomer.customerNumber = textBox4.Text; } else { MessageBox.Show("Please Enter Customer Number"); }

if (radioButton1.Checked) { label10.Text = "Customer wants to join mailing list"; }

else if (radioButton2.Checked) { label10.Text = "Customer does not want to join mailing list"; } }

private void button2_Click(object sender, EventArgs e) { this.Close(); } } }

Form1.cs Customer.cs Person.cs Forml.cs [Design] X Customer Information label! Customer Name abel2 Customer Address befstomer Phone Number. textBox1 = textBox2 = textBox3 = textBox4 label 4 Customer Number: Does Customer Wish to Be on Mailing List? -b 5 radioButton1 =-o Yes No radioBu = label6 = label7 label8 = ldbel9 label10 button 1 Display >Customer Exit = bu 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

500 450 400 350 300 250 0-1-2-3-4-5-6 i = 4% P 600 460 360 300 40/0

Answered: 1 week ago