XML

COMP3200 Anonymous Questions and Answers Keyword Index

This page provides a keyword index to questions and answers. Clicking on a keyword will take you to a page containing all questions and answers for that keyword, grouped by year.

To submit a question, use the anonymous questions page. You may find the keyword index and/or top-level index useful for locating past questions and answers.

Keyword reference for assign1

2024

Question 28 (2024):

Submission reference: IN3673

Write a method called spend that takes one int parameter.
The parameter value must be subtracted from the amount field only if the
parameter's value is not larger than the value of amount. You may assume
that the parameter will never be negative.
If the new amount in the money box is now smaller than leastMoney then this
method must also update leastMoney.
I dont understand how to do this piece of coding. Is there anyway I could get help?

Answer 28:

If you come to the drop-in at 3pm in Marlowe PC2 this afternoon then we can give you directed help with that.

Keywords: assign1


Question 26 (2024):

Submission reference: IN3671

For the second method addMoney am I supposed to write an if method as well? because I have written the code as a ++ and I didn't come up as an error so I'm not sure if I need to write an if

Answer 26:

The assignment says, 'The parameter value must be added to the amount field, but only if the parameter's value is greater than zero.' So, there will need to be an if-statement. Be careful about the way you increase the amount field because using ++ only adds 1 to a variable and you want the method to add whatever value is in the parameter into amount. The parameter's value will not necessarily be 1. Use the object inspector to check that the field is correct after the call.

Keywords: assign1 , method-addMoney


Question 25 (2024):

Submission reference: IN3670

I am unsure what is wrong with my code. This is the only error I have left to fix but I cannot see what is wrong. It says that the error is to do with my spend but I included my whole code

code deleted

Answer 25:

Thank you for including your code and the error message, which helps a lot.

If you have 50 pounds in the money box, should it be possible to spend 50 pounds? If so, does your code allow that?

Keywords: assign1 , method-spend


Question 24 (2024):

Submission reference: IN3669

For the assignment, when it says write a method addMoney that takes one int parameter, what is supposed to be in the parameter is it the name of the field or you can name it anything?

Answer 24:

You can call the parameter whatever you like, but I recommend not calling it 'amount' to avoid a name clash with the amount field. Give it a name that relates to the fact that it is an amount of money being put in the money box.

Keywords: assign1 , method-addMoney


Question 22 (2024):

Submission reference: IN3667

Just wanted to check whether my constructor is correct.

code deleted
Also, it is telling me to write a method called spend that takes one int parameter. I do not know how to subtract it from the amount field.

Answer 22:

You have the parameters correct, but the body of the constructor is not using the parameter values to initialise the fields. The name parameter must be used to initialise the name field and the amount parameter must be used to initialise the money fields.

Also, you have made lecturers a local variable rather than a field.

Keywords: assign1


Question 15 (2024):

Submission reference: IN3660

Where can we find the testing file to test the assignment and make sure everything works.

Answer 15:

When I have written it I will put it on the Moodle page.

Keywords: assign1

This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.
Last modified Fri Jan 17 08:25:20 2025
This document is maintained by David Barnes, to whom any comments and corrections should be addressed.