Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
Section A Object oriented programming
Except where otherwise stated, the questions in this Section should be answered assuming a C# environment using the Microsoft .NET Framework Class Library.
(a) Explain the key advantage of using a public property to access a private class variable, instead of a public variable, with no more than 50 words. [4 Marks]
(b) Explain three major differences between an abstract class and an interface,with no more than 30 words for each difference. [6 Marks]
(c) Explain the major similarity and the major difference between method hiding and method overriding, with no more than 70 words. [6 Marks]
(d) With the help of an example, explain how graphical user interface programming with Windows Presentation Foundation (WPF) utilises the inheritance concept of object-oriented programming, with no more than 50 words. [4 Marks]
You are asked to develop a NumberList class for some list operations. The partial source code of the NumberList class, a main program demonstrating the functionalities and the expected outputs are shown below. You are asked to implement the functionalities that can generate the outputs as shown. You should also do proper checking to ensure valid operations and memory storage.
The NumberList Class
public class NumberList
{
private int iSize ;
private List < int > lstI = new List < int >();
private Random ran = new Random ();
public NumberList ( int iSize )
{
this . iSize = iSize ;
for ( int i = 0; i < iSize ; i ++)
lstI . Add (0);
}
// Your implementations start here
}
The Main Program
static void Main ( string [] args )
{
NumberList N = new NumberList (5);
Console . WriteLine ( ” The ␣ original ␣ list : ” );
N . Print ( ” ,” );
N . RandomValues ();
Console . WriteLine ( ” The ␣ random – valued ␣ list : ” );
N . Print ( ” ,” );
Console . WriteLine ( ” Using ␣ \” – -\” ␣ as ␣ the ␣ separator : ” );
N . Print ( ” –” );
Console . WriteLine ( ” Reversing ␣ the ␣ list : ” );
N . Reverse ();
N . Print ( ” ,” );
Console . WriteLine ( ” Randomising ␣ the ␣ list ␣ order : ” );
N . RandomOrder ();
N . Print ( ” ,” );
N . RandomOrder ();
N . Print ( ” ,” );
N . RandomOrder ();
N . Print ( ” ,” );
}
The output of the main program.
(a) Write the function RandomValues in the NumberList class, which updates the values of each item in lstI with a random integer between 1 and 9 (inclusive of 1 and 9). Then, explain the programming logic with no more than 30 words. [4 Marks]
(b) Write the function Print in the NumberList class, which prints the content of lstI, with a separator text between two numbers passed as a function parameter. Then, explain the programming logic with no more than 50 words. [6 Marks]
(c) Write the function Reverse in the NumberList class, which reverses the order of the items in lstI. Then, explain the programming logic with no more than 50 words. [8 Marks]
(d) Write the function RandomOrder in the NumberList class, which randomises the order of the items in lstI. Then, explain the programming logic with no more than 70 words. [12 Marks]