Learning Outcomes:

  • Develop code comprehension skills for simple OOP programs.
  • Develop skills and experience in using generative AI tools such as GitHub Copilot.
  • Critically reflect on benefits and dangers of using generative AI tools to create software code.



You will use CodeRunner Exam to complete this activity.

Please note that CodeRunner will automatically close at the advertised deadline, without opportunity for late submissions.

Please don’t leave it to the last minute.


How to complete this assessment

  1. Install the GitHub Copilot extension in VS Code.
  2. There are four tasks to complete:
    • 3x programming tasks that involve using Copilot to write an OOP class by providing prompts to Copilot. We give you the code that needs to be generated, and so you need to think of the prompts that would generate this code.
    • 1x short reflection on your experience of using Copilot in completing the above programming tasks.
  3. For each programming task, the process involves:
    • Read the code provided. We give you the code that needs to be generated, and so you need to think of the prompts that would generate this code.
    • Download the starter code for the task, and open it in VS Code.
    • Write the prompts with Copilot. In VS Code, with GitHub Copilot enabled, write the prompts that would generate the code provided. You should write the prompts as comments (e.g., /** ... */ or //) of the code provided.
    • Check the code and submit in CodeRunner. When you are happy with the code generated by Copilot, copy the entire file content (including both the comments and generated code) and paste into CodeRunner. Check that the test cases pass in CodeRunner.
    • If any test cases fail, you got back and edit your prompts until you get the code to pass all the test cases. Do not edit the code directly. You are being assessed for your ability to write prompts to generate the code.

Note: You are not being assessed on the quality of the code generated by Copilot. You are being assessed on your ability to write prompts to generate the code. The code generated/proposed by Copilot does not need to be “exactly” the same character for character. What’s important is that it achieves the same functionality as the code provided and passes the required test cases in CodeRunner Exam.

Watch the following video to see an example of how to complete this assessment:




Task 1: SimpleMath

Targeted Output

Here is a screenshot of the functionality that you want Copilot to generate for you:

Edit

The first step is to comprehend what it is doing, and then thing of the prompts that would generate this code.

Note:

  • The target above doesn’t show any comments. You of course need to submit the comments along with the generated code.
  • Depending on the prompts you write in the comments, the code that you write might differ slightly. That’s OK. You are trying to get the same functionality so that it passes the test cases, even if it’s slightly different in the code generated.


Download the starter code for this task, and save it to your computer.

Download starter code for ‘SimpleMath.java’

Open the starter code in VS Code. You should see the following code:

Edit

You need to write prompts within either the comment blocks (/** ... */) or add some comments (e.g., //) of your own. You can write as many prompts as you want. You can also write prompts in multiple places.

Here is an example of how you can write prompts, along with the code suggested by Copilot:

Edit

Note: The prompt shown is purposely incorrect.

Press the tab key to accept the code suggested by Copilot:

Edit

You can continue to write more prompts and accept the code suggested by Copilot:

Edit

Sometimes you might need to delete some code that Copilot generates, or code that was already provided:

Edit

If you aren’t happy with the code generated by Copilot, highlight the prompts and code generated by Copilot:

Edit

And write your new prompts:

Edit

Accept the new code suggested by Copilot, by pressing the tab key:

Edit

Once you are happy with the prompts and code, copy the entire file content (including both the comments and generated code):

Edit

And paste into CodeRunner Exam. Check that the test cases pass in CodeRunner:

Edit

Remember, copy both the prompts and the code generated by Copilot into CodeRunner.

CodeRunner will only tell you if the code passes the test cases. It won’t warn you if you didn’t include the prompts, so you need to check this yourself.




Task 2: BankAccount

Targeted Output

Here is a screenshot of the functionality that you want Copilot to generate for you:

Edit


Download the starter code for this task, and save it to your computer.

Download starter code for ‘BankAccount.java’

Follow the same instructions as the previous task, but for the BankAccount class, and submit in CodeRunner.




Task 3: ShoppingCart

Targeted Output

Here is a screenshot of the functionality that you want Copilot to generate for you:

Edit


Download the starter code for this task, and save it to your computer.

Download starter code for ‘ShoppingCart.java’

Follow the same instructions as the previous tasks, but for the ShoppingCart class, and submit in CodeRunner.




Task 4: Final Reflection

Reflect on your use of Copilot to complete above programming tasks.

Some questions to consider:

  • What did you find easy about using Copilot?
  • What did you find difficult about using Copilot?
  • What did you learn about using Copilot?
  • What are the benefits of using Copilot?
  • What are the limitations of using Copilot?
  • What are the dangers of using Copilot?

You do not need to answer every single of these questions, these are just to guide you in your reflection. You can also add your own questions.

Submit your reflection in CodeRunner.

You should write at least 150 words. You can write more if you want to.