#toString

1 messages ยท Page 1 of 1 (latest)

minor lanternBOT
#

<@&987246399047479336> please have a look, thanks.

#

Here is an AI assisted attempt to answer your question ๐Ÿค–. Maybe it helps! In any case, a human is on the way ๐Ÿ‘. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#
TJ-Bot
I am so lost rn i normally ask chatGPT to help me and this is still makin 0 sense idk where i am getitng it wrong

When you call toString() on an object in Java, it returns a string representation of that object. By default, the toString() method provided by the Object class returns a string containing the class name and the memory address of the object.

You can override this method in your own classes to provide a custom string representation of your objects. This can be useful for debugging or displaying objects in a more meaningful way.

If you're having trouble understanding how toString() works or how to override it, here are some useful links to help you out:

Useful links:

  1. Java toString() method
  2. Customizing toString() for Better Debugging
  3. Effective Java - Item 12: Consider implementing Comparable
wise pecan
#

can i send u my code

gilded stream
#

What's the issue? You don't add Slot(SODA) anywhere in your toString method, so it won't contain Slot(SODA)

wise pecan
#

wym?

#

Does your code pass your tests?

Your code does not pass your tests. Hints follow.
hws.hw3.SlotTest.testToString() toString should mention the product type expected: [true] but was: [false]

gilded stream
#

What?

#

Do you know what your unit test does?

wise pecan
#

no?

#

i am just so lost

gilded stream
#

Let me guess, you used ChatGPT to write this and now you don't know what anything means?

wise pecan
#

yup it was just mainly on Tostring

#

like i literally figured out evrything for the most part and the logic but this wasnt clicking

gilded stream
#

So stop using ChatGPT and use your own brain so that you learn something

wise pecan
#

i use chatgpt as a tool to make me notes and practice question?

gilded stream
#

No, you used it to write your code

wise pecan
#

ight

gilded stream
#

So what are you confused about? Your unit test checks if toString returns a string containing "Slot(SODA)", but your toString method doesn't add "Slot(SODA)" to the result.

obsidian echo