Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Help with Visual C# 2012 Programming Problem For reference, this is Programming

ID: 3876328 • Letter: H

Question

Help with Visual C# 2012 Programming Problem

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."

So far, I have made the person class and the customer class. But, I'm not sure what to do for the application.

Customer.cs

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

namespace HW12CH10_4
{
class Customer: Person
{
int _customerNumber;
bool _mailing;

//customerNumber property create
public int 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 HW12CH10_4
{
class Person
{
string _name;
string _address;
string _phoneNumber;

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

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

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

Explanation / Answer

Question

"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."

------------------------------------------------------------------------------------------------------------------------------------------

Program

/*In this program i created two classess person and Customer.Cutomer is derived class of Person.So Customer class can access Persons attributes and methods.It's a simple program to show derived class access parent class and display details.*/

using System;

//Peron class
class Person
{
public string _name;
public string _address;
public string _phoneNumber;

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

//addres property
public string Address
{
get { return _address; }
set { _address = value; }
}
//Phone number property
public string PhoneNumber
{
get { return _phoneNumber; }
set { _phoneNumber = value; }
}
//Constructor creation
public Person(){}
public Person(string name, string address, string pno)
{
        this._name = name;
        this._address = address;
        this._phoneNumber = pno;
}

}

//Cutomer class
class Customer: Person
{
public int _customerNumber;
public bool _mailing;

//customerNumber property create
public int customerNumber
{
get { return _customerNumber; }
set { _customerNumber = value; }
}

//mailing property
public bool Mailing
{
get { return _mailing; }
set { _mailing = value; }
}
//Contructor creation
public Customer(){}
public Customer(int cno, bool mailing)
    {
        this._customerNumber= cno;
        this._mailing = mailing;
      
    }
}

//Main class

public class Test
{
   public static void Main()
   {
   //variables for user input  
       string cName;
                        string cAddress;
                        string cPhoneNumber;
                        int customerNumber;
                        bool mailing;
                      
                        //User inputting
       Console.WriteLine("Enter customer name : ");
       cName=Console.ReadLine();
      
       Console.WriteLine("Enter customer Address : ");
       cAddress=Console.ReadLine();
      
       Console.WriteLine("Enter Phone Number : ");
       cPhoneNumber=Console.ReadLine();
      
       Console.WriteLine("Enter Cutomer number : ");
       customerNumber= Convert.ToInt32(Console.ReadLine());
  
       //Cutomer class object creation and set method
                 Customer c=new Customer{
       _name=cName,
                         _address=cAddress,
                         _phoneNumber=cPhoneNumber,
                         _customerNumber=customerNumber,
                         _mailing=true
      
                    };
                   
       //Get method
       Console.WriteLine("Customer Name : "+c._name);
                         Console.WriteLine("Customer Address : "+c._address);
                         Console.WriteLine("Cutomer Phone Number : "+c._phoneNumber);
                         Console.WriteLine("Cutomer Number : "+c._customerNumber);
                         Console.WriteLine("Mailing needed or not : "+c._mailing);
      
   }
}

----------------------------------------------------------------------------------------------------------------------------------------------

Output:-

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote