By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,736 Members | 1,982 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,736 IT Pros & Developers. It's quick & easy.

Cant figure out what return type I need!

P: 3
I'm kind of new to java & I'm trying to do a grade project called Grade.java Its suposed to make a grade book but I keep on geting 2 errors. Both say return type required. I put the error points in Bold, Italic & underlined

Expand|Select|Wrap|Line Numbers
  1. /**
  2.  * Implementation class for the Student bean.
  3.  *
  4.  * <code><pre>
  5.  * CREATE TABLE amber_many2many_map (
  6.  *   grade_id INTEGER PRIMARY KEY auto_increment,
  7.  *
  8.  *   student_id INTEGER REFERENCES Student(student_id)
  9.  *   course_id INTEGER REFERENCES Course(course_id)
  10.  * );
  11.  * </pre></code>
  12.  */
  13. @Entity
  14. @Table(name="amber_many2many_map")
  15. public class Grade3 {
  16.   private long _id;
  17.   private Student _student;
  18.   private Course _course;
  19.   private String _grade;
  20.  
  21.   public Grade()
  22.   {
  23.   }
  24.  
  25. public Grade(Student student, Course course, String grade)
  26.   {
  27.     setStudent(student);
  28.     setCourse(course);
  29.     setGrade(grade);
  30.   }
  31.  
  32.   /**
  33.    * Gets the id.
  34.    */
  35.   @Id
  36.   @Column(name="grade_id")
  37.   @GeneratedValue
  38.   public long getId()
  39.   {
  40.     return _id;
  41.   }
  42.  
  43.   /**
  44.    * Sets the id.
  45.    */
  46.   public void setId(long id)
  47.   {
  48.     _id = id;
  49.   }
  50.  
  51.   /**
  52.    * Gets the grade.
  53.    */
  54.   @Basic
  55.   public String getGrade()
  56.   {
  57.     return _grade;
  58.   }
  59.  
  60.   /**
  61.    * Sets the grade.
  62.    */
  63.   public void setGrade(String grade)
  64.   {
  65.     _grade = grade;
  66.   }
  67.  
  68.   /**
  69.    * Returns the student.
  70.    */
  71.   @ManyToOne
  72.   @JoinColumn(name="student_id", nullable=false, updatable=false)
  73.   public Student getStudent()
  74.   {
  75.     return _student;
  76.   }
  77.  
  78.   /**
  79.    * Sets the student.
  80.    */
  81.   public void setStudent(Student student)
  82.   {
  83.     _student = student;
  84.   }
  85.  
  86.   /**
  87.    * Returns the course.
  88.    */
  89.   @ManyToOne
  90.   @JoinColumn(name="course_id", nullable=false, updatable=false)
  91.   public Course getCourse()
  92.   {
  93.     return _course;
  94.   }
  95.  
  96.   /**
  97.    * Sets the course.
  98.    */
  99.   public void setCourse(Course course)
  100.   {
  101.     _course = course;
  102.   }
  103. }
  104.  
Dec 14 '06 #1
Share this Question
Share on Google+
3 Replies


10K+
P: 13,264
I'm kind of new to java & I'm trying to do a grade project called Grade.java Its suposed to make a grade book but I keep on geting 2 errors. Both say return type required. I put the error points in Bold, Italic & underlined

Expand|Select|Wrap|Line Numbers
  1. /**
  2. * Implementation class for the Student bean.
  3. *
  4. * <code><pre>
  5. * CREATE TABLE amber_many2many_map (
  6. * grade_id INTEGER PRIMARY KEY auto_increment,
  7. *
  8. * student_id INTEGER REFERENCES Student(student_id)
  9. * course_id INTEGER REFERENCES Course(course_id)
  10. * );
  11. * </pre></code>
  12. */
  13. @Entity
  14. @Table(name="amber_many2many_map")
  15. public class Grade3 {
  16. private long _id;
  17. private Student _student;
  18. private Course _course;
  19. private String _grade;
  20.  
  21. public Grade()
  22. {
  23. }
  24.  
  25. public Grade(Student student, Course course, String grade)
  26. {
  27. setStudent(student);
  28. setCourse(course);
  29. setGrade(grade);
  30. }
  31.  
  32. /**
  33. * Gets the id.
  34. */
  35. @Id
  36. @Column(name="grade_id")
  37. @GeneratedValue
  38. public long getId()
  39. {
  40. return _id;
  41. }
  42.  
  43. /**
  44. * Sets the id.
  45. */
  46. public void setId(long id)
  47. {
  48. _id = id;
  49. }
  50.  
  51. /**
  52. * Gets the grade.
  53. */
  54. @Basic
  55. public String getGrade()
  56. {
  57. return _grade;
  58. }
  59.  
  60. /**
  61. * Sets the grade.
  62. */
  63. public void setGrade(String grade)
  64. {
  65. _grade = grade;
  66. }
  67.  
  68. /**
  69. * Returns the student.
  70. */
  71. @ManyToOne
  72. @JoinColumn(name="student_id", nullable=false, updatable=false)
  73. public Student getStudent()
  74. {
  75. return _student;
  76. }
  77.  
  78. /**
  79. * Sets the student.
  80. */
  81. public void setStudent(Student student)
  82. {
  83. _student = student;
  84. }
  85.  
  86. /**
  87. * Returns the course.
  88. */
  89. @ManyToOne
  90. @JoinColumn(name="course_id", nullable=false, updatable=false)
  91. public Course getCourse()
  92. {
  93. return _course;
  94. }
  95.  
  96. /**
  97. * Sets the course.
  98. */
  99. public void setCourse(Course course)
  100. {
  101. _course = course;
  102. }
  103. }
  104.  
Every method must have a return type unless it is a constructor. From your code your 2 methods are probably constructors. Now a constructor must have the same name as that of the class. So change the names of these 2 to public Grade3
Dec 14 '06 #2

P: 3
Every method must have a return type unless it is a constructor. From your code your 2 methods are probably constructors. Now a constructor must have the same name as that of the class. So change the names of these 2 to public Grade3
I did that & now I'm geting 18 errors. I put the error points in Bold, Italic & underlined again.

Expand|Select|Wrap|Line Numbers
  1. /**
  2. * Implementation class for the Student bean.
  3. * <code><pre>
  4. * CREATE TABLE amber_many2many_map (
  5. * grade_id INTEGER PRIMARY KEY auto_increment,
  6. * student_id INTEGER REFERENCES Student(student_id)
  7. * course_id INTEGER REFERENCES Course(course_id)
  8. * );
  9. * </pre></code>
  10. */
  11. @Entity
  12. //^Cannot Find Symbol
  13. @Table(name="amber_many2many_map")
  14. //^Cannot Find Symbol
  15. public class Grade3 {
  16. private long _id;
  17. private Student _student;
  18.          //^Cannot Find Symbol
  19. private Course _course;
  20.           //^Cannot Find Symbol
  21. private String _grade;
  22. public Grade3()
  23. {
  24. }
  25. public Grade3(Student student, Course course, String grade)   
  26.                     //^-------------------^Cannot Find Symbol
  27. {
  28. setStudent(student);
  29. setCourse(course);
  30. setGrade(grade);
  31. }
  32. /**
  33. * Gets the id.
  34. */
  35. @Id
  36. //^Cannot Find Symbol
  37. @Column(name="grade_id")
  38. //^Cannot Find Symbol
  39. @GeneratedValue
  40. //^Cannot Find Symbol
  41. public long getId()
  42. {
  43. return _id;
  44. }
  45. /**
  46. * Sets the id.
  47. */
  48. public void setId(long id)
  49. {
  50. _id = id;
  51. }
  52. /**
  53. * Gets the grade.
  54. */
  55. @Basic
  56. //^Cannot Find Symbol
  57. public String getGrade()
  58. {
  59. return _grade;
  60. }
  61. /**
  62. * Sets the grade.
  63. */
  64. public void setGrade(String grade)
  65. {
  66. _grade = grade;
  67. }
  68. /**
  69. * Returns the student.
  70. */
  71. @ManyToOne
  72. //^Cannot Find Symbol
  73. @JoinColumn(name="student_id", nullable=false, updatable=false)
  74. //^Cannot Find Symbol
  75. public Student getStudent()
  76.         //^Cannot Find Symbol
  77. {
  78. return _student;
  79. /**
  80. * Sets the student.
  81. */
  82. public void setStudent(Student student)
  83.                                 //^Cannot Find Symbol
  84. {
  85. _student = student;
  86. /**
  87. * Returns the course.
  88. */
  89. @ManyToOne
  90.   //^Cannot Find Symbol
  91. @JoinColumn(name="course_id", nullable=false, updatable=false)
  92.  //^Cannot Find Symbol
  93. public Course getCourse()
  94.          //^Cannot Find Symbol
  95. {
  96. return _course;
  97. }
  98. /**
  99. * Sets the course.
  100. */
  101. public void setCourse(Course course)
  102.                               //^Cannot Find Symbol
  103. {
  104. _course = course;
  105. }
  106. }
  107.  
Dec 14 '06 #3

10K+
P: 13,264
I did that & now I'm geting 18 errors. I put the error points in Bold, Italic & underlined again.

Expand|Select|Wrap|Line Numbers
  1. /**
  2. * Implementation class for the Student bean.
  3. * <code><pre>
  4. * CREATE TABLE amber_many2many_map (
  5. * grade_id INTEGER PRIMARY KEY auto_increment,
  6. * student_id INTEGER REFERENCES Student(student_id)
  7. * course_id INTEGER REFERENCES Course(course_id)
  8. * );
  9. * </pre></code>
  10. */
  11. @Entity
  12. //^Cannot Find Symbol
  13. @Table(name="amber_many2many_map")
  14. //^Cannot Find Symbol
  15. public class Grade3 {
  16. private long _id;
  17. private Student _student;
  18. //^Cannot Find Symbol
  19. private Course _course;
  20. //^Cannot Find Symbol
  21. private String _grade;
  22. public Grade3()
  23. {
  24. }
  25. public Grade3(Student student, Course course, String grade) 
  26. //^-------------------^Cannot Find Symbol
  27. {
  28. setStudent(student);
  29. setCourse(course);
  30. setGrade(grade);
  31. }
  32. /**
  33. * Gets the id.
  34. */
  35. @Id
  36. //^Cannot Find Symbol
  37. @Column(name="grade_id")
  38. //^Cannot Find Symbol
  39. @GeneratedValue
  40. //^Cannot Find Symbol
  41. public long getId()
  42. {
  43. return _id;
  44. }
  45. /**
  46. * Sets the id.
  47. */
  48. public void setId(long id)
  49. {
  50. _id = id;
  51. }
  52. /**
  53. * Gets the grade.
  54. */
  55. @Basic
  56. //^Cannot Find Symbol
  57. public String getGrade()
  58. {
  59. return _grade;
  60. }
  61. /**
  62. * Sets the grade.
  63. */
  64. public void setGrade(String grade)
  65. {
  66. _grade = grade;
  67. }
  68. /**
  69. * Returns the student.
  70. */
  71. @ManyToOne
  72. //^Cannot Find Symbol
  73. @JoinColumn(name="student_id", nullable=false, updatable=false)
  74. //^Cannot Find Symbol
  75. public Student getStudent()
  76. //^Cannot Find Symbol
  77. {
  78. return _student;
  79. /**
  80. * Sets the student.
  81. */
  82. public void setStudent(Student student)
  83. //^Cannot Find Symbol
  84. {
  85. _student = student;
  86. /**
  87. * Returns the course.
  88. */
  89. @ManyToOne
  90. //^Cannot Find Symbol
  91. @JoinColumn(name="course_id", nullable=false, updatable=false)
  92. //^Cannot Find Symbol
  93. public Course getCourse()
  94. //^Cannot Find Symbol
  95. {
  96. return _course;
  97. }
  98. /**
  99. * Sets the course.
  100. */
  101. public void setCourse(Course course)
  102. //^Cannot Find Symbol
  103. {
  104. _course = course;
  105. }
  106. }
  107.  

Do you have a class called Student? You are using it in the class Grade3 but the compiler does not know anything about it.
private Student _student;
Dec 14 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.