Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. TheRealFawcett:Lab8 therealfawcett$ java Student
  2. Error: Main method not found in class Student,
  3. please define the main method as:
  4. public static void main(String[] args)
  5. or a JavaFX application class must extend
  6. javafx.application.Application
  7. TheRealFawcett:Lab8 therealfawcett$
  8.  
  9. import java.io.*;
  10. import java.util.*;
  11.  
  12. public class Student {
  13. private static void main(String[] args) {
  14. Student student = new Student("Charles");
  15. }
  16.  
  17. private String forName;
  18. private String surName;
  19. private String studentID;
  20. private String degreeScheme;
  21.  
  22. //This is the Constructor of the
  23. public Student(String name) {
  24. this.forName = forName;
  25. }
  26.  
  27. //Assign the surname of the student
  28. public void stuSurname(String stuSurname) {
  29. surName = stuSurname;
  30. }
  31.  
  32. //Assign the student ID to the student
  33. public void stuID(String stuID) {
  34. studentID = stuID;
  35. }
  36.  
  37. //Assign the Degree of the Student
  38. public void stuDegree(String stuDegree) {
  39. degreeScheme = stuDegree;
  40. }
  41.  
  42. //Print the student details
  43. public void printStudent() {
  44. System.out.println("Forname:" + forName);
  45. System.out.println("Surename:" +
  46. surName);
  47. System.out.println("Student ID:" +
  48. studentID);
  49. System.out.println("Degree Scheme:" +
  50. degreeScheme);
  51. }
  52.  
  53. // setter
  54. public void setForName(String forName) {
  55. this.forName = forName;
  56. }
  57.  
  58. // getter
  59. public String getForName() {
  60. return forName;
  61. }
  62. }
  63.  
  64. import java.io.*;
  65.  
  66. public class StudentTest {
  67.  
  68. public static void main(String[] args) {
  69. /*create three new objects using constructor*/
  70. Student stuOne = new Student()
  71. Student stuTwo = new Student()
  72. Student stuThree = new Student()
  73.  
  74. //Invoking Methods for Each object Created
  75. stuOne.forName("James")
  76. stuOne.stuSurname("Smith")
  77. stuOne.stuID("0987")
  78. stuOne.stuDegree("Computer Science")
  79.  
  80. stuTwo.forName("Vanessa")
  81. stuTwo.stuSurname("Peach")
  82. stuTwo.stuID("0988")
  83. stuTwo.stuDegree("Mathematics")
  84.  
  85. stuThree.forName("George")
  86. stuThree.stuSurname("BlackSmith")
  87. stuThree.stuID("0989")
  88. stuThree.stuDegree("English")
  89. }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement