返回首页

大家好,

我学习C#,现在我想通过开发一个简单的学校系统练习,我学到了什么。我遇到了很多问题,我不知道为什么。我有很多的错误,当我编译它们如:

错误11超载的'SchoolSystem.Student.setGrade(INT)"比赛方法具有一些无效参数
请帮助我。

我的代码是:


using System;

 

namespace SchoolSystem {

 

    public class Student {

 

        //Variables

        string name;

        string id;

        double grade;

 

        //Constructors

        public Student() : this("Default Constructor") { }

 

        public Student(string name)

        {

 

            this.Name = name;

        }

 

        public Student(string name, string id)

        {

 

            this.Name = name;

            this.Id = id;

        }

 

        public Student(string name, string id, double grade) {

 

            this.Name = name;

            this.Id = id;

            this.Grade = grade;

        }

 

        //Accessors

        public string getName(){

        

            return name;

        }

 

        public string getId(){

        

            return id;

        }

 

        public int getGrade()

        {

        

            return grade;

        }

        

        //Mutators

        public string setName(string newName){

        

            name = newName;

        }

 

        public string setId(string newId){

        

            id = newId;

        }

 

        public int setGrade(int newGrade){

        

            grade = newGrade;

        }

 

    }

 

    public class SchoolSystem{

    

        public static void Main(String [] args){

 

            Console.WriteLine("-----------------------------------");

            Console.WriteLine("Welcome to Dhahran Secondary School");

            Console.WriteLine("-----------------------------------");

 

            Student s1 = new Student();

            Console.WriteLine("Please enter the student name: ");

            s1.setName(Console.ReadLine());

            Console.WriteLine("Please enter the student id: ");

            s1.setId(Console.ReadLine());

            Console.WriteLine("Please enter the student grade: ");

            s1.setGrade(Console.ReadLine());

 

            Student s2 = new Student();

            Console.WriteLine("Please enter the student name: ");

            s2.setName(Console.ReadLine());

            Console.WriteLine("Please enter the student id: ");

            s2.setId(Console.ReadLine());

            Console.WriteLine("Please enter the student grade: ");

            s2.setGrade(Console.ReadLine());

 

            Student s3 = new Student();

            Console.WriteLine("Please enter the student name: ");

            s3.setName(Console.ReadLine());

            Console.WriteLine("Please enter the student id: ");

            s3.setId(Console.ReadLine());

            Console.WriteLine("Please enter the student grade: ");

            s3.setGrade(Console.ReadLine());

 

            Console.WriteLine("The System Information");

            Console.WriteLine("The information of: {0}", s1.getName(), "\nID: ", s1.getId(), "\nGrade: ", s1.getGrade());

            Console.WriteLine("The information of: {0}", s2.getName(), "\nID: ", s2.getId(), "\nGrade: ", s2.getGrade());

            Console.WriteLine("The information of: {0}", s3.getName(), "\nID: ", s3.getId(), "\nGrade: ", s3.getGrade());

 

            Console.ReadLine();

        } 

    }

 



}

 

| matrix388

回答

评论会员: 时间:2