Skip to content

Instantly share code, notes, and snippets.

@bilijo
Last active June 8, 2017 19:13
Show Gist options
  • Save bilijo/1d798400630e35ad8f5acad2c1355875 to your computer and use it in GitHub Desktop.
Save bilijo/1d798400630e35ad8f5acad2c1355875 to your computer and use it in GitHub Desktop.
report card class - v1
/**
* This Class is indented to manage some grades informations about a student.
* A teacher is able to set and get, grade notes relative to some courses the student follows
*
* @author (damir Males)
* @version (v1 02 juin 2017)
*/
public class ReportCard
{
// instance variables will contains the student name and three grades , math, history and french
private String studentName = "";
private String mathGrade = "";
private String historyGrade = "";
private String frenchGrade = "";
/**
* Constructor for objects of class ReportCard
*/
public ReportCard(String mStudentName, String mMathGrade, String mHistoryGrade, String mFrenchGrade )
{
// initialize instance variables
studentName = mStudentName;
mathGrade = mMathGrade;
historyGrade = mHistoryGrade;
frenchGrade = mFrenchGrade;
}
/**
* get the student name of the report card
*/
public String getStudentName()
{
return studentName;
}
/**
* get the math grade of the student
*/
public String getMathGrade()
{
return mathGrade;
}
/**
* get the history grade of the student
*/
public String getHistoryGrade()
{
return historyGrade;
}
/**
* get the french grade of the student
*/
public String getFrenchGrade()
{
return frenchGrade;
}
/**
* Set the student name of the report card
*/
public void setStudentName(String mStudentName)
{
studentName = mStudentName;
}
/**
* Set the math grade of the student
*/
public void setMathGrade(String mMathGrade)
{
mathGrade = mMathGrade;
}
/**
* Set the history grade of the student
*/
public void setHistoryGrade(String mHistoryGrade)
{
historyGrade = mHistoryGrade;
}
/**
* Set the french grade of the student
*/
public void setFrenchGrade(String mFrenchGrade)
{
frenchGrade = mFrenchGrade;
}
/**
* Concatenate all datas included in the class using the toString method
*/
public String toString() {
return "Student's Name" + this.studentName +
" : Math's Grade " + this.mathGrade +
", History's Grade " + this.historyGrade +
", French's Grade " + this.frenchGrade;
}
}
@bilijo
Copy link
Author

bilijo commented Jun 8, 2017

Same naming convention between variables declared in the constructor and these used int sets and gets functions

@bilijo
Copy link
Author

bilijo commented Jun 8, 2017

Adding toString() method to the class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment