Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TheRealFawcett:Lab8 therealfawcett$ java Student
- Error: Main method not found in class Student,
- please define the main method as:
- public static void main(String[] args)
- or a JavaFX application class must extend
- javafx.application.Application
- TheRealFawcett:Lab8 therealfawcett$
- import java.io.*;
- import java.util.*;
- public class Student {
- private static void main(String[] args) {
- Student student = new Student("Charles");
- }
- private String forName;
- private String surName;
- private String studentID;
- private String degreeScheme;
- //This is the Constructor of the
- public Student(String name) {
- this.forName = forName;
- }
- //Assign the surname of the student
- public void stuSurname(String stuSurname) {
- surName = stuSurname;
- }
- //Assign the student ID to the student
- public void stuID(String stuID) {
- studentID = stuID;
- }
- //Assign the Degree of the Student
- public void stuDegree(String stuDegree) {
- degreeScheme = stuDegree;
- }
- //Print the student details
- public void printStudent() {
- System.out.println("Forname:" + forName);
- System.out.println("Surename:" +
- surName);
- System.out.println("Student ID:" +
- studentID);
- System.out.println("Degree Scheme:" +
- degreeScheme);
- }
- // setter
- public void setForName(String forName) {
- this.forName = forName;
- }
- // getter
- public String getForName() {
- return forName;
- }
- }
- import java.io.*;
- public class StudentTest {
- public static void main(String[] args) {
- /*create three new objects using constructor*/
- Student stuOne = new Student()
- Student stuTwo = new Student()
- Student stuThree = new Student()
- //Invoking Methods for Each object Created
- stuOne.forName("James")
- stuOne.stuSurname("Smith")
- stuOne.stuID("0987")
- stuOne.stuDegree("Computer Science")
- stuTwo.forName("Vanessa")
- stuTwo.stuSurname("Peach")
- stuTwo.stuID("0988")
- stuTwo.stuDegree("Mathematics")
- stuThree.forName("George")
- stuThree.stuSurname("BlackSmith")
- stuThree.stuID("0989")
- stuThree.stuDegree("English")
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement