Question: Visual Studio c# (Inheritance) Part #1 - Create the Person class. Go to the Menu and select project. Under project, select Add class. Then start

Visual Studio c# (Inheritance)

Part #1 - Create the Person class. Go to the Menu and select project. Under project, select Add class. Then start typing in your code for a Person class. Properties: Name, Address, Phone, Email. Behaviors: set and get methods, Display(outputs all person data to the Output window using Console.WriteLine()).

Part #2 Modify the Student class that you created in the last lab to use the new Person class. Indicate that the Student class inherits from the Person class. Remove any properties that are already in the Person class. Modify the constructors and the display method, to use code from the Person class.

Your Form class code should not change at all. It should work exactly the same as in the previous lab. If you find yourself changing the code in your Form class, you are probably doing something wrong.

class Student

{

// Properties

private string name;

private string address;

private string phone;

private string email;

private string major;

private double gpa;

// Constructor

public Student()

{

name = "";

address = "";

phone = "";

email = "";

major = "";

gpa = 0.0;

}

// Constructor

public Student(string Name, string Address, string Phone, string Email, string Major, double Gpa)

{

Name = name;

Address = address;

Phone = phone;

Email = email;

Major = major;

Gpa = gpa;

}

// Behaviors

public string Name

{

get { return name; }

set { name = value; }

}

public string Address

{

get { return address; }

set { address = value; }

}

public string Phone

{

get { return phone; }

set { phone = value; }

}

public string Email

{

get { return email; }

set { email = value; }

}

public string Major

{

get { return major; }

set { major = value; }

}

public double GPA

{

get { return gpa; }

set { gpa = value; }

}

// Display method

public void Display()

{

// Print all student data to the Console

Console.WriteLine("Name: " + Name);

Console.WriteLine("Address: " + Address);

Console.WriteLine("Phone: " + Phone);

Console.WriteLine("Email: " + Email);

Console.WriteLine("Major: " +Major);

Console.WriteLine("GPA: " +GPA.ToString());

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!