Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

ITS D004 Programming Fundamentals

2021

SECTION A

Question 1 (25 marks)

(a)       List all Primitive Data Types in Java.

(4 marks)

(b)       Show the Java code that satisfy the following:

1)  Takes TWO (2) numbers as input.

2)  Display the sum of TWO (2) numbers.

(6 marks)

(c)       Show the Java code that takes a number as input and prints its multiplication table up to 10.

(10 marks)

(d)       Explain in your own words, describing the purpose of each escape sequences.

i)         \n

ii)        \t

iii)       \\

iv)       \”

v)        \r

(5 marks)

Question 2 (25 marks)

(a)       Explain in your own words and illustrate with a diagram on the memory concepts

of Java.

(10 marks)

(b)       Write the Java code to reverse a string.

For example:

Input a String: The quick brown fox

Output in reverse: xof nworb kciuq ehT

(8 marks)

(c)

for(int z = 0; z < 20; z++){

System.out.println(z);

}

Based on the Java code snippet above. Rewrite the for loop in the print method, into a while loop.

(7 marks)

SECTION B

Question 3 (25 marks)

The International Chess Federation or World Chess Federation, commonly referred to by its French acronym FIDE, is an international organization based in Switzerland that connects the various national chess federations and acts as the governing body of international chess competition. Due to COVID- 19 restriction worldwide, it is difficult to host a face-to-face competition. To keep up the chess spirit amongst enthusiast, FIDE is planning a virtual chess competition, allowing remote chess competition worldwide. This competition will be hosted on a chess gaming platform created by FIDE called, World Chess. This allows instant setup of competition and live spectators to view any ongoing matches. However, FIDE does not have a score tracking application to log data as an internal use. In order to support the smooth conduct of the competition, you will

be required to develop a Java Program that manages the tracking.

Based on the case study above, answer the following questions.

(a)       Begin by writing a Class that will represent a chess player in a package called

ChessPlayer. We want to be able to access the class  ChessPlayer from  any package.

Once you are done writing the Class. Add the following fields, which cannot be accessed outside of the Class.

-    Player name

-    Player age

-    Player chess experience in years

-    Player win records

-    Player loss records

(10 marks)

(b)       Write a constructor that accepts the player’s name, age, chess experience in years,

win and loss records. This constructor should be accessible from any package.    (6 marks)

(c)       Illustrate the UML Class Diagram used in (a) and (b).

(7 marks)

(d)       In your own words, explain the use of Access Modifiers.

(2 marks)

Question 4 (25 marks)

Reusing and Continuing from Question 3 case study.

Answer the following questions.

(a)       Write FIVE (5) methods that will return the name ofthe player’s name, age, chess

experience in years, win and loss records. These methods should be accessible from any package. For win and loss records, write TWO (2) methods to update the records with conditional statement to prevent negative values.

Note: These methods are an add-on to the ChessPlayer class.

(8 marks)

(b)       Write/Declare an array for the chess player object class. Write ONE (1) method

to add chess player object to the array.

(7 marks)

(c)       Write ONE (1) method to increase the number of chess experience in years by any amount. These methods should only be accessible from inside the chessplayer package.

Note: These methods are an add-on to the ChessPlayer class.

(2 marks)

(d)       Finally, show the code that satisfy the following:

1)  Write ONE (1) main method to the ChessPlayerManagement class

2)  Within the main method, construct a ChessPlayer named John Doe”, age 25,

3 years chess experiences, with 10 wins and 8 losses.

3)  Write ONE (1) call to the method to add John Doe” ChessPlayer object to the array.

4)  Lastly, write ONE (1) call to the method that increases the numbers of wins by 3.

(8 marks)