0% found this document useful (0 votes)
2 views

Tutorial1-Classes and Objects (Part2)_2025_V2.Docx

The document outlines a tutorial on object-oriented programming, focusing on the design and implementation of an attendance management system for a training school and a cinema application for movie screenings. It includes exercises that require the identification of classes, attributes, methods, and modifications to enhance functionality, such as tracking student absences and managing reservations. The document also emphasizes testing the systems with various scenarios to ensure proper functionality.

Uploaded by

fylexhatestiktok
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Tutorial1-Classes and Objects (Part2)_2025_V2.Docx

The document outlines a tutorial on object-oriented programming, focusing on the design and implementation of an attendance management system for a training school and a cinema application for movie screenings. It includes exercises that require the identification of classes, attributes, methods, and modifications to enhance functionality, such as tracking student absences and managing reservations. The document also emphasizes testing the systems with various scenarios to ensure proper functionality.

Uploaded by

fylexhatestiktok
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Ecole nationale Supérieure d’Informatique (ESI) 2CPI​ ​ 2024/2025

Object-oriented programming

Tutorial 1. Classes and objects (Part2)

Exercise 4:
The attendance service of a training school wants to automate the management of student absences in
training workshops. A student is characterized by their first name, last name, student ID, and an absence
counter. Each training program is identified by a unique code (e.g., Or11), has a name, a list of enrolled
students, and the workshops that have taken place. We assume that a student is enrolled in only one training
program at a time, and a training program cannot have more than 30 students and 10 workshops. A
workshop for a given training program is held on a specific date and time (e.g., workshop for the Or11
training program on 16/02/2025 at 14:30). After each workshop, the instructor submits the list of absent
students to the attendance service. The service records this list for the corresponding workshop and updates
its status from planned to conducted.

The system should be able to:

●​ Display the list of enrolled students for each training program, along with their total number of
absences.
●​ Display the list of planned workshops for a given training program.
●​ Display the list of conducted workshops for a given training program.
●​ Display the list of absent students for a given workshop.

Q1 a. Design an object-oriented solution by identifying the necessary classes, their attributes, and their
methods.

b. Implement your solution and test it using the provided main function:

public class Main {

public static void main(String[] args) {

​ // Create an attendance service object


AttendanceService service = new AttendanceService();

// Create a training
Training training = new Training("Or11", "Oracle");
service.addTraining(training);

// Create students
Student s1 = new Student("Ali", "Ahmed", "S001");
Student s2 = new Student("Sara", "Belaid", "S002");
Student s3 = new Student("Omar", "Kacem", "S003");

training.addStudent(s1);
training.addStudent(s2);
training.addStudent(s3);

Workshop w1 = new Workshop("16/02/2025", "14:30");


Workshop w2 = new Workshop("17/02/2025", "10:00");

1/3
Ecole nationale Supérieure d’Informatique (ESI) 2CPI​ ​ 2024/2025

Object-oriented programming

Workshop w3 = new Workshop("19/02/2025", "16:00");


Workshop w4 = new Workshop("25/02/2025", "10:00");

training.addWorkshop(w1);
training.addWorkshop(w2);
training.addWorkshop(w3);
​ training.addWorkshop(w4);

Student[] absenteesW1 = {s1, s2};


Student[] absenteesW2 = {s3};
Student[] absenteesW3 = {s1};

//The service records the workshop absentees and updates its status
service.recordAbsences(w1, absenteesW1);
service.recordAbsences(w2, absenteesW2);
service.recordAbsences(w3, absenteesW3);

// Display the asked information


service.displayEnrolledStudents();
service.displayWorkshops(training);
service.displayWorkshops(training,”Conducted”);
service.displayAbsentees(w1);
}
}

Q2: The attendance service wants more details about student absences. It now requires a list of all
workshops each student was absent from, along with the corresponding date and time.

a. Identify the necessary modifications to fulfill this requirement.​


b. Implement your solution.

Q3. We want to restrict the display operations by using System.out.println only in the main method. To
achieve this, the display methods should return a String instead of being void.

a. Make the necessary modifications.​


b. What is the benefit of this modification?

Note: To create a String incrementally, use the StringBuilder class and its append method to concatenate
Strings efficiently.

Exercice 5

A cinema wants to develop an application to display the list of scheduled movie screenings. The cinema has
a name, an address, and multiple rooms. Each room is identified by a number, has a seating capacity, and a
list of scheduled screenings. A screening is identified by a number, a date, a start time, an end time, a ticket
price, and the movie being shown.

2/3
Ecole nationale Supérieure d’Informatique (ESI) 2CPI​ ​ 2024/2025

Object-oriented programming

Users can browse the list of scheduled screenings, and see detailed information about each movie: its title,
production year, director's name, list of actors, and synopsis (a short summary).

In addition to viewing information, the application offers customers the ability to reserve a seat for a
screening. To do this, the customer enters their customer number and the screening number they wish to
attend. The application checks whether the customer number exists in the list of customers and whether seats
are available. If valid, the reservation is confirmed, and the ticket price (with a discount if applicable) as well
as the reservation number are displayed to the customer. Customers who have attended more than 25
screenings receive a 5% discount on all future tickets. Payment is made on the day of the screening. The
customer presents their reservation number. The application verifies the reservation. If valid, the reservation
status changes to "used", preventing multiple uses.

1.​ Design an object-oriented solution for this application. Identify the classes, their attributes, and their
methods, and draw a class diagram with relationships.
2.​ Implement the solution in Java and test the movie display functionality with a cinema containing
three rooms, each showing a movie in two sessions (one in the early afternoon and one in the
evening).
3.​ Test the reservation system with:
●​ A customer with fewer than 25 past screenings (who pays full price).
●​ A customer with 30 past screenings (who gets a 5% discount).
●​ A customer attempting to book a screening that is already fully booked.
●​ A customer trying to reserve a ticket with an invalid customer number.
●​ A customer trying to validate a reservation with an existing reservation number.
●​ A customer trying to validate a reservation with a non-existent or already used reservation number.

3/3

You might also like