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 method-setType

2024

Question 52 (2024):

Submission reference: IN3697

hi, I have tried to find the mistake for hours and I still dont understand what is wrong because the error that comes up says I am comparing 2 strings with an '==' but I am just reassigning the variable so when, it is displayed it has an X next to the number, but it seems to not work. Here is my code:

    public void setType(String name, String type) {
	 code deleted
		String updatedType = restaurant.getFoodType() + "X";
		return ;
         code deleted
	    }
Thank you.

Answer 52:

If you want to change the type of a Restaurant object then you have to call the type setter method on it. At the moment, you are just getting the food type and changing the local variable, so you are not mutating the Restaurant object at all.

Keywords: assign2 , method-setType

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.