Revise Student.java and Lab7.java to include Javadoc comments instead of the com
ID: 3551833 • Letter: R
Question
Revise Student.java and Lab7.java to include Javadoc comments instead of the comments they contain
now. Include a javadoc comment for (1) each class as a whole (before the class declaration), and (2) before each
public method. Try to use reasonable descriptions, and include block tags for every parameter and return
value.
public class Lab7
{
// Constants
private final static String NAME = "mike";
private final static int STUID = 451236541;
private final static double GPA1 = 4.00;
private final static double GPA2 = 2.34;
public static void main (String[] args)
{
Student stu1;
stu1 = new Student(NAME, STUID, GPA1);
System.out.println(" Name: " + stu1.getName());
System.out.println("Id Number: " + stu1.getIdNum());
System.out.println("GPA: " + stu1.getGPA());
stu1.setGPA(GPA2);
System.out.println(stu1 + " ");
Student stu2;
stu2 = new Student("Pistol Pete",000000001,4.00);
System.out.println(" Name: " + stu2.getName());
System.out.println("Id Number: " + stu2.getIdNum());
System.out.println("GPA: " + stu2.getGPA());
stu2.setGPA(GPA1);
System.out.println(stu2 + " ");
}
}
public class Student
{
private String name;
private int idNum;
private double gpa;
public Student(String namePar, int idNumPar, double gpaPar)
{
name = namePar;
idNum = idNumPar;
gpa = gpaPar;
}
public String getName()
{
return name;
}
public double getGPA()
{
return gpa;
}
public int getIdNum()
{
return idNum;
}
public void setStudentName(String n)
{
name = n;
}
public void setGPA(double g)
{
gpa = g;
}
public String toString()
{
return "Student name: "+ getName() + " " +"Student ID: "+getIdNum()+" "+"Student GPA: "+getGPA();
}
Explanation / Answer
Link to Code and JavaDoc
https://www.dropbox.com/sh/ykxeytwjm0w4d1r/OxopDEH5am
Code
Lab7.java
/**
* THis class is a driver for Student class
* It creates a student object and tests the various methods of student class
* @author pratikkumar
* @version 1.0
*/
public class Lab7
{
private final static String NAME = "mike";
private final static int STUID = 451236541;
private final static double GPA1 = 4.00;
private final static double GPA2 = 2.34;
/**
* This function creates a student object
* Sets various parameters of the student object
* Tests all the methods of the Student object
* @param args command line arguments if required
*/
public static void main (String[] args)
{
Student stu1;
stu1 = new Student(NAME, STUID, GPA1);
System.out.println(" Name: " + stu1.getName());
System.out.println("Id Number: " + stu1.getIdNum());
System.out.println("GPA: " + stu1.getGPA());
stu1.setGPA(GPA2);
System.out.println(stu1 + " ");
Student stu2;
stu2 = new Student("Pistol Pete",000000001,4.00);
System.out.println(" Name: " + stu2.getName());
System.out.println("Id Number: " + stu2.getIdNum());
System.out.println("GPA: " + stu2.getGPA());
stu2.setGPA(GPA1);
System.out.println(stu2 + " ");
}
}
Student.java
/**
* This class contains the information about a student
* It stores the name, id and gpa of the student
* @author pratikkumar
* @version 1.0
*/
public class Student
{
private String name;
private int idNum;
private double gpa;
/**
* This is the constructor of the class Student
* It sets the name, ID and GPA of the student that is passed as parameters
* @param namePar name of the student to be set in the object
* @param idNumPar id of the student to be set in the object
* @param gpaPar gpa of the student to be set in the object
*/
public Student(String namePar, int idNumPar, double gpaPar)
{
name = namePar;
idNum = idNumPar;
gpa = gpaPar;
}
/**
* This function returns the name of the student
* @return name of the student
*/
public String getName()
{
return name;
}
/**
* This function returns the GPA of the student
* @return GPA of the student
*/
public double getGPA()
{
return gpa;
}
/**
* This function returns the Id Number of the student
* @return ID Number of the student
*/
public int getIdNum()
{
return idNum;
}
/**
* This function sets the name of the student
* @param n name of the student to be set in the object
*/
public void setStudentName(String n)
{
name = n;
}
/**
* This function sets the GPA of the student
* @param g GPA of the student to be set in the object
*/
public void setGPA(double g)
{
gpa = g;
}
/**
* This function returns the string equivalent of the object
* @return string equivalent of the object
*/
public String toString()
{
return "Student name: "+ getName() + " " +"Student ID: "+getIdNum()+" "+"Student GPA: "+getGPA();
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.