Answer to Question #238596 in C# for Phamela

Question #238596

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 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 Open and edit your console application to handle the updated requirements. Update the Member class to include the following methods: public void diplayMember() //Display the name and points for a member int IComparable.CompareTo(object obj) //Used to sort the array in ascending order of name


1
Expert's answer
2021-09-17T15:01:07-0400




using System;
using System.Collections.Generic;
namespace MemberApp
{
    class Member : IComparable
    {
        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 P)
        {
            this.Points = P;
        }


        public void diplayMember()
        {
            Console.WriteLine("Name: " + Name + "\n" + "Points: " + Points + "\n");
        }


        int IComparable.CompareTo(object obj)
        {
            return this.Name.CompareTo(((Member)obj).Name);
        }
    }






    class Program
    {


       
        static void Main(string[] args)
        {


           
            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
APPROVED BY CLIENTS