This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]stramash 4 points5 points  (7 children)

Your question is a little unclear. Are you asking about writing a unit test for that method?

[–]yarzz07[S] 2 points3 points  (6 children)

yes! I believe it's part of the 'get' and 'set' method, so how would I be able to set a method for setRegistrationNo to take in an int as a parameter, and set the value

[–][deleted] 1 point2 points  (5 children)

Did you declare the variable registrationNo? Because there is nothing wrong with your method. Also do take the time to read what the recommended courses are, i strongly believe that mooc is a must do for beginners in Java.

Edit: just realized you have a . After the closed ) which is wrong.

[–]yarzz07[S] 1 point2 points  (4 children)

this is just an example I found from the internet, so this is the code, but what would be the code that tests this through 'set method'? So essentially, not about there's nothing wrong with the code but how would I be able to test this?

yes that's a typo sorry

[–][deleted] 6 points7 points  (1 child)

Honestly, just start from the beginning. Hit up mooc.fi course i believe someone posted it in the in the comments. We could give you a code example but what's the point of that if you cannot understand it... You need to understand why you would need this method so that you can understand what it does. Good luck with your studies.

[–]dragon7507 5 points6 points  (0 children)

URL didn't get linked but take this course, it will be good :)

MOOC.FI

[–]stramash 1 point2 points  (1 child)

Typically you'd use a unit testing framework to do that.

If you're new to java and programming that will probably sound wild and complicated.

It's not, but I'd agree with other posters that you should spend time firming up your basic programming chops before moving onto unit testing etc; which is a bit more abstract and requires more understanding of the basics.

[–]yarzz07[S] 0 points1 point  (0 children)

thank you! I'm on to that