Difference between revisions of "Section C 2022"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
(Created page with "This section is to document the skeleton program. Section C will be questions relating to the actual code within the program and could relate to specific methods, variables, p...")
 
Line 1: Line 1:
 
This section is to document the skeleton program. Section C will be questions relating to the actual code within the program and could relate to specific methods, variables, programming skills, or theory topics.
 
This section is to document the skeleton program. Section C will be questions relating to the actual code within the program and could relate to specific methods, variables, programming skills, or theory topics.
 +
 +
=Execution=
 +
The 'static void Main' in the class of program will always be the first block of code executed.
 +
 +
The line:
 +
<syntaxhighlight lang=c#>
 +
Breakthrough ThisGame = new Breakthrough();
 +
</syntaxhighlight>
 +
 +
Declares and instantiates an object of 'Breakthrough', this will cause the constructor method of the 'Breakthrough' class to be run. The code for the constructor is below:
 +
 +
<syntaxhighlight lang=c#>
 +
        public Breakthrough()
 +
        {
 +
            Deck = new CardCollection("DECK");
 +
            Hand = new CardCollection("HAND");
 +
            Sequence = new CardCollection("SEQUENCE");
 +
            Discard = new CardCollection("DISCARD");
 +
            Score = 0;
 +
            LoadLocks();
 +
        }
 +
</syntaxhighlight>
 +
 +
As you can see, this calls the 'LoadLocks' method of the 'Breakthrough' class. The 'LoadLocks' method will execute and doesn't make any other called to other methods.
 +
 +
So back to the 'static void Main' and this line:
 +
 +
<syntaxhighlight lang=c#>
 +
ThisGame.PlayGame();
 +
</syntaxhighlight>
 +
 +
This calls the 'PlayGame' method of the 'Breakthrough' object.
  
 
=Classes=
 
=Classes=

Revision as of 08:55, 2 September 2021

This section is to document the skeleton program. Section C will be questions relating to the actual code within the program and could relate to specific methods, variables, programming skills, or theory topics.

Execution

The 'static void Main' in the class of program will always be the first block of code executed.

The line:

Breakthrough ThisGame = new Breakthrough();

Declares and instantiates an object of 'Breakthrough', this will cause the constructor method of the 'Breakthrough' class to be run. The code for the constructor is below:

        public Breakthrough()
        {
            Deck = new CardCollection("DECK");
            Hand = new CardCollection("HAND");
            Sequence = new CardCollection("SEQUENCE");
            Discard = new CardCollection("DISCARD");
            Score = 0;
            LoadLocks();
        }

As you can see, this calls the 'LoadLocks' method of the 'Breakthrough' class. The 'LoadLocks' method will execute and doesn't make any other called to other methods.

So back to the 'static void Main' and this line:

ThisGame.PlayGame();

This calls the 'PlayGame' method of the 'Breakthrough' object.

Classes

The skeleton program has the following classes:

2022 - Breakthrough

2022 - Challenge

2022 - Lock

2022 - Card

2022 - ToolCard

2022 - DifficultyCard

2022 - CardCollection

2022 - Program

Question Help

  • Private vs Protected
  • Virtual & Override
  • About 'Inheritance' & Polymorphism'
  • About the use of 'this'
  • About the use of 'base'
  • Constructors
  • Static
  • Lists