return语句未返回值

时间:2018-09-26 12:41:45

标签: java return-value

我有一个Java练习,试图创建一个学生数据数据库。

为此,我创建了一个工作正常的帐号。我还添加了考试成绩,并使用return语句为他们分配了一个值。现在,我已经为成绩指定了值。我想创建一个取决于成绩的入学分数。

但是我跑步

System.out.println(enroll(maths, english, french, history)); 

我的分数返回0。

package studentDataBaseProject;

import java.util.Random;

public class studentDataBaseBasePage {

    String firstname;
    String surname;
    String nI;
    private final String eMail = "@test.com";
    private static int studentId = 22230;
    Integer random;
    private String uniqueUserId;
    private String english;
    private String maths;
    private String history;
    private String french;
    private String gradeCalculation;

//    student Unique ID
    studentDataBaseBasePage(String firstname, String surname, String nI) {
        String eMAilAddress = firstname + "." + surname + eMail;
        System.out.println("email address: " + eMAilAddress + ", Student ID: " + studentId);
        studentId++;
//      System.out.println(studentId);
        int randomNumber = new Random().nextInt(9999 - 1000) + 1000;
        uniqueUserId = studentId + randomNumber + nI.substring(3, 6);
        System.out.println(firstname + "'s " + "Unique ID: " + studentId + uniqueUserId);
        System.out.println(enroll(maths, english, french, history));
    }
// getters and setters for grades
    public void setEnglish(String english) {
        this.english = english;
    }

    public String getEnglish() {
        return gradeValues(english);
    }

    public void setMaths(String maths) {
        this.maths = maths;
    }

    public String getMaths() {
        return gradeValues(maths);

    }

    public void setHistory(String history) {
        this.history = history;
    }

    public String getHistory() {
        return gradeValues(history);

    }

    public void setFrench(String french) {
        this.french = french;

    }

    public String getFrench() {
        return gradeValues(french);

    }
// conversion of grades to values
    public String gradeValues(String subjectGrade) {

        if (subjectGrade == "A") {
            subjectGrade = "5";
        } else if (subjectGrade == "B") {
            subjectGrade = "4";
        } else if (subjectGrade == "C")
            subjectGrade = "3";
         else if (subjectGrade == "D") {
            subjectGrade = "2";
        }else if (subjectGrade == "E") {
            subjectGrade = "1";
        }
        else subjectGrade = "0";

        return subjectGrade;


    }
// entrance score for college
    public String enroll(String maths, String english, String french, String history) {
     gradeCalculation = maths + french + english + history;
    return gradeValues(gradeCalculation);

}

    private void pay() {
//          cost to join
    }

    private void checkBalance() {
//      balance in the students account
    }

    private void showCourses() {
//      course available
    }
}

0 个答案:

没有答案