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

OOP LAB EXER 2 - Classes and Objects

This document provides an exercise to write an object-oriented program for a sports team membership application. The program should allow participants to select between a basketball or volleyball team, input their name and age, check if they qualify based on age requirements, store qualified applicants in an array, display acceptance/rejection messages, and output all accepted applicants when exiting. It includes UML class diagrams and algorithms for creating Team and Member objects to represent the application.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
180 views

OOP LAB EXER 2 - Classes and Objects

This document provides an exercise to write an object-oriented program for a sports team membership application. The program should allow participants to select between a basketball or volleyball team, input their name and age, check if they qualify based on age requirements, store qualified applicants in an array, display acceptance/rejection messages, and output all accepted applicants when exiting. It includes UML class diagrams and algorithms for creating Team and Member objects to represent the application.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

CS129-8L OBJECT-ORIENTED PROGRAMMING LABORATORY

Exercise no. 2
Classes and Objects

Objective/s: To write an object-oriented program focusing on the concept of objects and classes and to learn
how to translate a UML diagram into a program.

Machine Problem/Problem Exercise

Team Membership Application

XYZ Team Membership application for a sports league is needed for the upcoming sportsfest. The league is composed of
the volleyball team and basketball team. Each team is recruiting members to fill-in their open slots. Write a Java Console
application program that will be used for the recruitment of the team members.

NOTE: Watch the video demos that I provided to guide you in doing this exercise.

The program should do the ff:

1. Show the participant the given menu

Select Team
------------------
[1] Basketball
[2] Volleyball
[3] Exit
------------------
Choice:

2. Let the participant make the selection (1 or 2).


3. Prompt the participant to input the following information after making the selection.

Enter name:
Enter age:

4. Check if the participant is qualified to join his/her chosen team based on the required age.

Team Open Minimu Maximum


slots m Age Age
Basketball 2 18 21
Volleyball 3 14 17

Store the applicant in an array if he/she is qualified to join the team.


5. Display a message that will tell if the participant has successfully joined the team or not.

Example:
Participant is qualified  “Welcome to the Basketball Team!”
Participant is not qualified  “Sorry, you are not qualified!”

6. Let the participant know when the team has already reached the required number of members.

Example: When the Basketball team has already recruited 2 participants, display:
“Basketball team is no longer accepting applicants.”

7. When the Exit option is selected, display the name of all successful applicants of each team then terminate the
program.

UML Class Diagrams

The array of team members should be declared as follows:

Member [] members = new Member[2]; - size is 2 for basketball team; 3 for volleyball team.
Algorithm for the main application (Form1 application)

1. Create the basketball and volleyball teams and assign the following values:

Team Maximum Minimu Maximum


Members m Age Age
Basketball 2 18 21
Volleyball 3 14 17

To create them, write the ff. Codes:

Team basketball = new Team (“Cardinals”, 2, 18, 21);


Team volleyball = new Team (“Mapua Lady Cardinals”, 3, 17, 19);

2. Create a member object that will represent the applicant of the team.

NOTE:
 The output of the program should be the same as that of Exercise 1. You have just written an object-
oriented version in Exercise 2.
 You should have the following files in your project after finishing the program:

MyLibs
o Member.java
o Team.java

MyApp
o Test.java

You might also like