Create a console application for a club to record their member information. For each member to need to store the member’s name and merit points. All new members starts with 0 merit points. Implement class Member which has private attributes for Name and Points. You need to create at a constructor method and the class also needs to have the following methods: public string getName() //Returns the name of the member public int getPoints() //Returns the points of the member public void setPoints(int P) //Sets the points of the member In the application class (main method in the program.cs file), do the following: Create two instances of Member, for John and Susan Assign merit points to each of them Use an if statement to display the name of the member with the highest points.
class Program
{
static void Main()
{
Member memberJonh = new Member("Jonh");
Member memberSusan = new Member("Susan");
memberJonh.setPoints(50);
memberSusan.setPoints(30);
if (memberJonh.getPoints() > memberSusan.getPoints())
Console.WriteLine("{0} has more points",memberJonh.getName());
else
Console.WriteLine("{0} has more points", memberSusan.getName());
Console.ReadKey();
}
}
class Member
{
string Name;
int Point;
public Member(string name)
{
Name = name;
}
public string getName()
{
return Name;
}
public int getPoints()
{
return Point;
}
public void setPoints(int P)
{
Point = P;
}
}
Comments
Leave a comment