Write 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
using System;
using System.Collections.Generic;
namespace MemberApp
{
class Member
{
private string Name;
private int Points;
public Member(string name, int points = 0)
{
this.Name = name;
this.Points = points;
}
public string getName()
{
return Name;
}
public int getPoints()
{
return Points;
}
public void setPoints(int points)
{
this.Points = points;
}
public override string ToString()
{
return "Name: " + Name + "\n" + "Points: " + Points + "\n";
}
}
class Program
{
static void Main(string[] args)
{
Member Peter = new Member("Peter");
Peter.setPoints(10);
Member Mary = new Member("Mary");
Mary.setPoints(20);
Console.WriteLine(Peter.ToString());
Console.WriteLine(Mary.ToString());
Console.ReadLine();
}
}
}
Comments
Leave a comment