473,405 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Cant figure out what return type I need!

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
3 1730
r035198x
13,262 8TB
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
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
r035198x
13,262 8TB
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

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

Similar topics

7
by: Nalaka | last post by:
Hi, I created a sinple web service that returns a dataSet. Then I created a client program that uses this web service (that returns the Dataset). My question is, how did the client figure...
0
by: importantEmail | last post by:
hi i have pasted page_load, my bindgrid, sort and itemdatabound event. my sorting in not working properly...i tried a couple of ways but there is something i am missing. pls suggest me on this...
0
by: samir dsf | last post by:
hi i have pasted page_load, my bindgrid, sort and itemdatabound event. my sorting in not working properly...i tried a couple of ways but there is something i am missing. pls suggest me on this...
2
by: g35rider | last post by:
Hi, I have the following code that is giving this error, I cant simplify the code, I was just testing some theory for something we are doing and was getting an issue here. Please someone point out...
5
by: Ouwet5775 | last post by:
Hello peeps. Well i have tried runing the folwoing program several times, and i cant figure out what i am doing wrong. The goal of this is to input values for an array, find the maximum and the...
17
by: so many sites so little time | last post by:
all right so the script is pretty simple it goes it retrives what the id of the post is and it lets you edit it well no it doesnt. now if you go to www.kirewire.com/pp2/index/php you will see a...
2
by: andrewanderson | last post by:
hi can anyone help me with this prog. cant find the prob why it cant display cout<<"This is the display of your transaction"<<endl; ifstream fobj; //declare input file stream ...
9
by: Steve Richter | last post by:
in a generic class, can I code the class so that I can call a static method of the generic class T? In the ConvertFrom method of the generic TypeConvert class I want to write, I have a call to...
127
by: sanjay.vasudevan | last post by:
Why are the following declarations invalid in C? int f(); int f(); It would be great if anyone could also explain the design decision for such a language restricton. Regards, Sanjay
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.