Create a class named Course_Details that will contain get and set methods for the course name,
student numbers and lecturer. In the Course_Details class include a method called Assign Venue
that will randomly generate a Venue/Class for the course. Venues can be from 1 to 3 only. Your
main class must include a static method to handle the printing of the course report.
package course_details;
import java.util.Random;
public class Course_Details {
private String course_name;
private String lecturer;
private int student_numbers;
void setCourseName(String name){
course_name = name;
}
void setLecturer(String l){
lecturer = l;
}
void setStudentNumber(int n){
student_numbers = n;
}
String getCourseName(){
return course_name;
}
String getLecturer(){
return lecturer;
}
int getStudent_number(){
return student_numbers;
}
//Function to generate a venue between 1 and 3
public static int Assign_Value(){
Random random = new Random();
int x = random.nextInt(3) + 1;
return x;
}
public static void print_coure_report(String course_name,String lecturer,int student_numbers){
System.out.print("Course Report\n");
System.out.print("****************************\n");
System.out.print("COURSE NAME:\t");
System.out.print(course_name);
System.out.print("\n");
System.out.print("STUDENT NUMBERS:\t");
System.out.print(student_numbers +"\n");
System.out.print("LECTURER:\t"+ lecturer+"\n");
System.out.print("VENUE:\t"+Assign_Value()+"\n");
}
public static void main(String[] args) {
String course_name;
String lecturer;
int student_numbers;
//Some course details to test the code
course_name = "Fundamental of Computing";
lecturer = "Dr. Vincent Kamata";
student_numbers = 40;
print_coure_report(course_name,lecturer, student_numbers);
}
}
Comments
Leave a comment