Answer to Question #238488 in C# for Phamela

Question #238488

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


1
Expert's answer
2021-09-17T09:22:17-0400




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();
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS