create a class named course details that will contain get and set methods for the course name student and lecturer. in the course details class include a method called assign venue that will randomly generate a venue 1 to 3 only your method must include a static method to handle printing
course code DISD, DIWD,DIDM
student number 35,28,39
lecturer mr jones , mrs smith, mr ntsinga
there should be a JoptionPane
import java.util.Random;
public class CourseDetails {
private String courseName;
private int studentNumbers;
private String lecturer;
public String getCourseName() {
return courseName;
}
public void setCourseName(String courseName) {
this.courseName = courseName;
}
public int getStudentNumbers() {
return studentNumbers;
}
public void setStudentNumbers(int studentNumbers) {
this.studentNumbers = studentNumbers;
}
public String getLecturer() {
return lecturer;
}
public void setLecturer(String lecturer) {
this.lecturer = lecturer;
}
public int assignVenue() {
return new Random().nextInt(3) + 1;
}
}
import javax.swing.*;
public class Main extends JFrame {
public Main(){
CourseDetails courseDetails = new CourseDetails();
courseDetails.setCourseName("DISD");
courseDetails.setLecturer("mr jones");
courseDetails.setStudentNumbers(35);
JOptionPane.showMessageDialog(this,"Course Report"
+"\nCOURSE NAME: " + courseDetails.getCourseName()
+"\nSTUDENT NUMBERS: " + courseDetails.getStudentNumbers()
+"\nLECTURER: " + courseDetails.getLecturer()
+"\nVenue/Class " + courseDetails.assignVenue(),"Report",JOptionPane.INFORMATION_MESSAGE);
}
public static void main(String[] args) {
new Main();
}
}
Comments
Leave a comment