Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 15

NAME DIVISHA JEGATHEES

REGISTRATION NO 25DDT21F1072 MARK

CLASS DDT3IS2
CODE/SUBJECT DFP30243 – OBJECT ORIENTED
PROGRAMMING
ASSESSMENT LABORATORY TASK 4 / 100

LECTURER MADAM ZALIHAR BINTI EMBONG

CLO 1: Construct Object Oriented Programming Concept and Exception Handling in Java Programming
(P4, PLO3)

TOPIC: 5.1 Perform Concept of Exception Handling

Duration: 2 Hours (100 Marks)

INSTRUCTION – 1. START YOUR PROGRAM WITH THE FOLLOWING SECTIONS


//NAME:
//REGISTRATION NUMBER:
//CLASS:
//ASSESSMENT: LABORATORY TASK 4
2. SAVE YOUR WORK AS
[YOUR_REGISTRATION_NUMBER_FILENAME.JAVA] EXAMPLE:
25DDT19F1054_TEAM.JAVA
3. SUBMIT YOUR ANSWER IN HARDCOPY OR SOFTCOPY VIA PLATFORM ASSIGNED BY
YOUR LECTURER

ANSWER ALL QUESTION

As a die-hard fan of Mobile Legends Professional League (MPL), Dede Riat plans to develop a simple
Java program to get information for top ten squad participants on MPL Malaysia Season 10. You as a
junior Java programmer are required to help Dede Riat to write the program according to the
following requirements:

a. Identify and construct appropriate classes with suitable attributes and methods.
b. The program should implement inheritance concept with super keyword being implemented.
c. Use appropriate exception handling to catch the exception by printing a statement
“ArithmeticException occurred. Cannot enter zero or negative number” when user entered
number equal to zero or less than zero as per Figure 2.
d. The input for the program is only an integer numbered between one until eleven. Integer
ONE until TEN are exclusively for the top ten squad participants information as per Figure 3.
e. Whereas integer ELEVEN is to exit the program with a printing statement “Bye bye. See you
again!” as per Figure 4.
f. If number bigger than eleven is entered, the program will be terminating with a printing
statement “Invalid number. Choose number from menu only” as per Figure 5.
g. If non integer is entered, the program will keep asking for the correct input with a printing
statement “Only digit is accepted! Enter number from the menu: “ as per Figure 6.
h. Use the finally block in the exception handling to print a statement “:::::: THANK YOU FOR
USING THIS SYSTEM ::::::” which will appear at the end of the program output no matter
what input has been entered.

1
Information of the top ten squad participants is given in Figure 1 below:

1. TEAM HAQ
Player Roster : Waff, Garyy, Mann, Syamskyyy, Panda, Minn, Lolla
Manager : Azmil
Coach : Pabz
Analyst : Adeen
Achievement : ONE Esports MPL Invitational 2022, MPL Malaysia Season 10, MPL
Malaysia Season 10 - Qualifier
Prize : $3000, $29000

2. TODAK
Player Roster : Momo, 4Meyz, Rival, Moon, CikuGais, Yums
Manager : Ashi
Coach : Hazim, Amoux
Analyst : No Information
Achievement : ONE Esports MPL Invitational 2022, MPL Malaysia Season 10, MPL
Malaysia Season 9
Prize : $9000, $17100, $29200

Player Roster : Neo, Born, Subway, Stormie, Valenz, Aim, Haru


Manager : Alice
Coach : Aush
Analyst : No Information
Achievement : ONE Esports MPL Invitational 2022, MPL Malaysia Season 10, MLBB
Southeast Asia Cup 2022, MPL Malaysia Season 9
Prize : $2000, $10800, $10000, $15200

4. RSG MALAYSIA
Player Roster : Iris, Kuza, Leixia, LinkEzaa, Izanami, Lolealz, Hyhy, Hawk, Sifu
Manager : xArm
Coach : Kuja
Analyst : No Information
Achievement : MPL Malaysia Season 9, Malaysian Esports Selection 2022, Malaysia
Esports Championship 2021
Prize : $7900, $4600, $957

5. HOMEBOIS
Player Roster : Anip, Chibi, Inferni, Vins, Sepat, Makdi, Benggg, XpDEA, Zacus,
Aul, Ombong
Manager : Avaa, Sushi
Coach : Skadaga, Saiful
Analyst : KILLUA
Achievement : MPL Malaysia Season 10, GMX Cup Season 1, MPL Malaysia Season 9,
Malaysian Esports Selection 2022
Prize : $6100, $56, $5200, $4310

2
6. RED ESPORTS MY
Player Roster : No
Information Manager : No
Information Coach : No
Information Analyst : No
Information Achievement : No
Information Prize : No
Information

7. TEAMLUNATIC
Player Roster : No
Information Manager : No
Information Coach : No
Information Analyst : No
Information Achievement : No
Information Prize : No
Information

8. TEAM SMG
Player Roster : Smooth, Box, ZAIMSEMPOI,Hatred, Sasa, Nuar,
Xorn Manager : Benny
Coach : Jamess
Analyst : Loong
Achievement : MPL Malaysia Season 10, MPL Malaysia Season
9 Prize : $5400, $5900

9. SUHAZ ESPORTS
Player Roster : No
Information Manager : No
Information Coach : No
Information Analyst : No
Information Achievement : No
Information Prize : No
Information

10. TEAM CARACAL


Player Roster : Syno, Eavy, Wynn, Aj, Zedd, Maima,
DAce Manager : Tupai
Coach : Padel, Jerong
Analyst : No

Figure 1: Top Ten Squad Information

3
Output sample of the program has been given as per Figure 2 until Figure 6 shown below.

Figure 2: Output Sample 1 (Input -2)

Figure 3: Output Sample 2 (Input 8)

4
Figure 4: Output Sample 3 (Input 11)

Figure 5: Output Sample 4 (Input 14)

5
Figure 6: Output Sample 5 (Input +, 2.2, 8)

**Note: You can use your creativity to display an output.

Zuraidah Binti Mohd


Ramly Ketua Program
(Trek Pembangunan Aplikasi Dan Perisian)
Jabatan Teknologi Maklumat &
Komunikasi Politeknik Mersing

6
ANSWER:
CLASS MPL_TEAM (SUPER CLASS)
//NAME:DIVISHA JEGATHEES
//REGISTRATION NUMBER:25DDT21F1072
//CLASS:DDT3IS2
//ASSESSMENT:LABORATORY 4

public class MPL_Team


{
public String PlayerRoster;
public String Manager;
public String Coach;
public String Analyst;
public String Achievement;
public String Price;

public MPL_Team(String PlayerRoster, String Manager,


String Coach, String Analyst, String Achievement, String Price)
{
this.PlayerRoster=PlayerRoster;
this.Manager=Manager;
this.Coach=Coach;
this.Analyst=Analyst;
this.Achievement=Achievement;
this.Price=Price;
}

public void display()


{
System.out.println ("PlayerRoster: " +PlayerRoster);
System.out.println ("Manager: " +Manager);
System.out.println ("Coach: " +Coach);
System.out.println ("Analyst: " +Analyst);
System.out.println ("Achievement: " +Achievement);
System.out.println ("Price: " +Price);
System.out.println ("--------------------THANK YOU
FOR USING THIS SYSTEM--------------------");
}
}
CLASS PARTICIPANTS (SUB CLASS)
//NAME:DIVISHA JEGATHEES
//REGISTRATION NUMBER:25DDT21F1072
//CLASS:DDT3IS2
//ASSESSMENT:LABORATORY 4

public class Participants extends MPL_Team


{
public Participants (String PlayerRoster, String Manager,
String Coach, String Analyst, String Achievement, String Price)
{
super(PlayerRoster, Manager, Coach, Analyst,
Achievement, Price);
}

public void display()


{
super.display();
}
}
CLASS TESTPARTICIPANTS (MAIN METHOD)
//NAME:DIVISHA JEGATHEES
//REGISTRATION NUMBER:25DDT21F1072
//CLASS:DDT3IS2
//ASSESSMENT:LABORATORY 4

import java.util.Scanner;
import java.io.*;
import java.util.InputMismatchException;
public class TestParticipants
{
public static void main(String[] args)
{
Scanner scan=new Scanner(System.in);
int choice;
boolean error = true;
System.out.println("--------------------MPL MALAYSIA SEASON 10
(2022)--------------------");
System.out.println("--------------------SYSTEM MENU : CHOOSE TEAM
INFO--------------------");
System.out.println("1. TEAM HAQ");
System.out.println("2. TODAK");
System.out.println("3. ORANGES ESPORTS");
System.out.println("4. RSG MALAYSIA");
System.out.println("5. HOMEBOIS");
System.out.println("6. RED ESPORTS MY");
System.out.println("7. TEAMLUNATIC");
System.out.println("8. TEAM SMG");
System.out.println("9. SUHAZ ESPORTS");
System.out.println("10. TEAM CARACAL");
System.out.println("----To exit from Menu choose number 11----");

System.out.print("Else,enter MPL Malaysia team number


for more info : ");

do{

try
{

choice=scan.nextInt();
if(choice==1)
{
System.out.println("1. TEAM HAQ");
MPL_Team t1=new Participants("Waff, Garyy, Mann,
Syamskyy, Panda, Minn, Lolla","Azmil","Pabz","Adeen","ONE Esports MPL
Invitational 2022, MPL Malaysia Season 10, MPL Malaysia Season 10 -
Qualifier","$3000, $29000");
t1.display();
}

else if(choice==2)
{
System.out.println("2. TODAK");
MPL_Team t2=new Participants("Momo, 4Meyz, Rival,
Moon, CikuGais","Ashi","Hashi, Amoux","No Information","ONE Esports
MPL Invitational 2022, MPL Malaysia Season 9, MPL Malaysia Season 10 -
Qualifier","$9000, $17000, $29200");
t2.display();
}
else if(choice==3)
{
System.out.println("3. ORANGES ESPORTS");
MPL_Team t3=new Participants("Neo, Born, Subway,
Stormie, Valenz, Aim, Haru","Alice","Aush","No Information","ONE Esports
MPL Invitational 2022, MPL Malaysia Season 10, MPL Malaysia Season 10
- Qualifier","$2000, $10800, $10000, $15200");
t3.display();
}

else if(choice==4)
{
System.out.println("4. RSG MALAYSIA");
MPL_Team t4=new Participants("Iris, Kuza, Leixia, LinkEzaa,
Izenami, Lolealz, Hyhy, Hawk, Sifu","xArm","Kuja","No Information","MPL
Malaysia Season 9, Malaysian Esports Selection 2022, Malaysia Esports
Championship 2021","$7900, $4600, $957");
t4.display();
}

else if(choice==5)
{
System.out.println("5. HOMEBOIS");
MPL_Team t5=new Participants("Anip, Chibi, Inferni, Vins,
Sepat, Makdi, Bangg, XpDEA, Zacus, Aul, Ombong","Avaa,
Sushi","Skadaga, Saiful","KILLUA","MPL Malaysia Season 9, Malaysian
Esports Selection 2022, Malaysia Esports Championship 2021","$6100,
$56, $5200, $4310");
t5.display();
}

else if(choice==6)
{
System.out.println("6. RED ESPORTS MY");
MPL_Team t6=new Participants("No Information","No
Information","No Information","No Information","No Information","No
Information");
t6.display();
}

else if(choice==7)
{
System.out.println("7. TEAMLUNATIC");
MPL_Team t7=new Participants("No Information","No
Information","No Information","No Information","No Information","No
Information");
t7.display();
}

else if(choice==8)
{
System.out.println("8. TEAM SMG");
MPL_Team t8=new Participants("Smooth, Box,
ZAIMSEMPOI, Hatred, Sasa, Nuar, Xorn","Benny","Jamess","Loong","MPL
Malaysia Season 10, MPL Malaysia Season 9","$5400, $5900");
t8.display();
}

else if(choice==9)
{
System.out.println("9. SUHAZ ESPORTS");
MPL_Team t9=new Participants("No Information","No
Information","No Information","No Information","No Information","No
Information");
t9.display();
}

else if(choice==10)
{
System.out.println("10. TEAM CARACAL");
MPL_Team t10=new Participants("Syno, Eavy, Wynn, Aj, Zedd,
Maima, DAce ","Tupai","Padel, Jerong","No Information","MPL Malaysia
Season 10, MPL Malaysia Season 9","$2800, $6400");
t10.display();
}

else if(choice==11)
{
System.out.println("Bye bye. See you again !");
System.out.println ("--------------------THANK YOU FOR
USING THIS SYSTEM--------------------");
}

else if(choice>11)
{
System.out.println("Invalid Number. Choose number from menu
only.");
System.out.println ("--------------------THANK YOU FOR
USING THIS SYSTEM--------------------");
}

else
{
System.out.println("ArithmeticException occured. Cannot
enter zero or negative number.");
System.out.println ("--------------------THANK YOU FOR
USING THIS SYSTEM--------------------");
}
}

catch(InputMismatchException e)
{
System.out.println("Only digit is accepted");
System.out.print("Enter number from the menu:
");
error = true;
scan.nextLine();

}while (error);

}
}
OUTPUT
OUTPUT 1(INPUT -2)

OUTPUT 2(INPUT 5)
OUTPUT 3(INPUT 11)

OUTPUT 4(INPUT 16)


OUTPUT 5(INPUT *, 7.9, 2)
SCORING FORM
COURSE CODE & NAME : DFP30243 - OBJECT ORIENTED PROGRAMMING
TYPE OF ASSESSMENT TASK : LABORATORY TASK 4
COURSE LEARNING OUTCOME : CLO1 - CONSTRUCT OBJECT ORIENTED PROGRAMMING CONCEPT AND EXCEPTION HANDLING IN JAVA
PROGRAMMING (P4, PLO3)

NO. STUDENT NAME REGISTRATION NUMBER DATE


1 DIVISHA JEGATHESS 25DDT21F1072 27.11.2022

MARKS
WEIGHTAGE
EXCELLENT GOOD AVERAGE WEAK Example :
CRITERIA CRITERIA (3/4)*20 = 15
4 3 2 1 % S1
Able to declare all classes
Able to declare all classes
using proper, clear, and Able to declare some classes Able to declare some
using meaningful name BUT
Class Declaration understandable name AND using vague class names BUT classes using vague class names 5
with or without access
suitable access specifier with access specifier. AND without access specifier.
specifier.
perfectly.
Able to declare proper, Able to declare all variables Able to declare all variables
clear, and understandable using meaningful name with using meaningful name Able to declare variables
Variable Declaration variable name with suitable access specifier and data without access specifier/ use with vague names with or 5
access specifier and type. default access specifier without suitable data type.
suitable data type. with data type.
Able to use suitable Able to use some technique Able to use little technique to
Able to use excellent technique
technique to manipulate data to manipulate data manipulate data conversion
Data Conversion to manipulate data conversion 5
conversion and produce conversion but does not with major error and incorrect
and produce correct result.
partially correct result. produce correct result. result.

Able to write all the input & Able to write all the input & Able to write all the input &
Able to write the input &
Input & Output output statements as expected output statements as output statements as
output statements with 5
Statement given based on the expected given based on the expected given based on the
unexpected output.
scenario. scenario. scenario.

Able to write code and use the Able to write most of the
Able to write some of the Students able to write some of
correct selection statement and selection statement but does
Selection Statement selection statement with the selection statement with 5
clearly solves not derive a solution to the
minor errors. major errors.
the problem. problem.

Able to write code and use the Able to write most of the loop
Able to write some of the Students able to write some of
correct loop statement and statement but does not
Looping Statement loop statement with the loop statement with major 5
clearly solves derive a solution to the
minor errors. errors.
the problem. problem.

Able to create object for Able to create object for


Able to create objects class
correct class perfectly to call correct class to call some of
Object Oriented Concept but fails to call correct Able to create object only. 5
all the methods or state the methods or state
method or state.
correctly. correctly.
Able to declare accurate, Able to declare methods Able to declare methods
clear, and understandable using meaningful name with using meaningful name with
Able to declare methods
Method Declaration and methods name with access access specifier and access specifier and
with vague names and not 10
Definition specifier and methods are definitions of methods definitions of methods
able to define the methods.
perfect and contains all the contain some tasks contain some tasks
task correctly correctly. correctly.
Able to apply inheritance
Able to apply inheritance using Able to apply inheritance Able to apply inheritance using
using both ‘extends’ and
Inheritance Concept both ‘extends’ and super using both ‘extends’ OR both ‘extends’ OR super
super keyword perfectly BUT 10
(Superclass and Subclass) keyword perfectly AND get the super keyword perfectly BUT keyword perfectly BUT with
with unexpected
output as expected. with expected output. unexpected output.
output.

Able to write code and use try- Able to write code and use try-
Able to write code and use
Exception Handling catch-finally blocks excellently catch-finally blocks with Able to write code and use try
try-catch blocks with correct 30
(try-catch-finally) with correct output and no correct output and minor blocks with correct output.
output.
error. error.

The code is exceptionally well The code is readable only by


Code Readability The code is poorly organized
organized, very easy to follow The code is easy to be read. someone who knows what it 10
and Comment and very difficult to read.
and include a few comments. is supposed to be doing.

Able to compile and execute Able to compile and execute Not able to compile the
Program Compilation Able to compile the program
and Execution
the program with expected the programs with Zuraidah Binti Mohd
with minor errors.
program with major errors. 5
output. unexpected output.
Ramly Ketua Program
(Trek Pembangunan Aplikasi Dan Perisian)
OVERALL TOTAL 100

Jabatan Teknologi Maklumat &


*Zero (0) mark will be given if students do not answer / perform the criteria needed
Komunikasi Politeknik Mersing

You might also like