Untitled
unknown
java
2 months ago
2.1 kB
7
Indexable
Never
import java.time.LocalDate; public class Booking { //=============================================================== // INSTANCE VARIABLE //=============================================================== private int bookingId; private LocalDate bookingDate; private Classroom classroom; private Lecturer lecturer; //=============================================================== // CONSTRUCTOR //=============================================================== public Booking(LocalDate bookingDate, Classroom classroom, Lecturer lecturer) { this.bookingId = generateNextId(); this.bookingDate = bookingDate; this.classroom = classroom; this.lecturer = lecturer; } //=============================================================== // GENERATE ID //=============================================================== private static int nextId = 50001; private static int generateNextId() { //return current id and increment return nextId++; } //=============================================================== // SETTER //=============================================================== public void setBookingDate(LocalDate bookingDate) { this.bookingDate = bookingDate; } public void setClassroom(Classroom classroom) { this.classroom = classroom; } public void setLecturer(Lecturer lecturer) { this.lecturer = lecturer; } //=============================================================== // GETTER //=============================================================== public int getBookingId() { return bookingId; } public LocalDate getBookingDate() { return bookingDate; } public Classroom getClassroom() { return classroom; } public Lecturer getLecturer() { return lecturer; } public String toString() { return " Booking ID: " + bookingId + " Booking Date: " + bookingDate + " Classroom: " + classroom + " Lecturer: " + lecturer; } }
Leave a Comment