Question: I have asked this question already and the answer I recieved was hardly changed from my original code. I have since revised my code and

I have asked this question already and the answer I recieved was hardly changed from my original code. I have since revised my code and could really use some help on it.

This is what I need help adding to my code. I will post my code below it.

Add Constructors to the Student class.

Add 2 constructors to the Student class. One that takes no arguments and initializes the data to all 0s and (empty strings). And one constructor that takes 6 arguments, one argument for each property and then sets the properties to these arguments that are passed in. Lastly change your event code, to use these new Constructors. You will not need to call the set functions any more, but do not remove the set functions from your class.

Change Part #3 from Lab #10 to now use these constructors.

Student s1; //declare as global data

//Fill Button

s1 = new Student(567, Susan Fry, Atl, 770-221-5555, ACCT, 3.2f);

//Display Button

s1.display();

namespace Students { public class Student { private string Name; private string Address; private string Phone; private string Email; private string Major; double GPA;

public string getName() { return Name; } public void setName(string name) { Name = name; }

public string getAddress() { return Address; } public void setAddress(string address) { Address = address; }

public string getPhone() { return Phone; } public void setPhone(string phone) { Phone = phone; }

public string getEmail() { return Email; } public void setemail(string email) { Email = email; }

public string getMajor() { return Major; } public void setMajor(string major) { Major = major; }

public double getGPA() { return GPA; } public void setGPA(double gpa) { GPA = gpa; }

public void Display() { Console.WriteLine("Name = " + getName()); Console.WriteLine("Address = " + getAddress()); Console.WriteLine("Phone = " + getPhone()); Console.WriteLine("Email = " + getEmail()); Console.WriteLine("Major = " + getMajor()); Console.WriteLine("GPA = " + getGPA());

} } }

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

Student s1;

void fillBtn_Click(object sender, EventArgs e) { s1 = new Student(); s1.setName("Bill"); s1.setAddress("ATL"); s1.setPhone("678-222-5555"); s1.setemail("email"); s1.setMajor("ACCT"); s1.setGPA(Convert.ToDouble(3.2)); }

private void dislpayBtn_Click(object sender, EventArgs e) { s1.Display(); }

private void exitBtn_Click(object sender, EventArgs e) { DialogResult dialog = MessageBox.Show("Do you want to close the program?", "SomeTitle", MessageBoxButtons.YesNo); if (dialog == DialogResult.Yes) { Application.Exit(); } else if (dialog == DialogResult.No) { //do nothing } } } }

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!