Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Use rating.equals("asd") for readibility
Also rating.toLowerCase().equals("asd")
Would be the best -
Don't feel bad. You even thought about using the right comparison order "constant".equals() instead of var.equals() which many beginners get wrong. Keep it up! :-)
-
@RazorSh4rk but what if rating == null? It would crash. The way he did it will not crash if rating is null.
-
Redrield6688y@SirWindfield let's just say i refuse to do JVM things without Kotlin and leave it at that :)
-
Next time don't add a comment like the one on line 29. It describes what is being done on line 30 and thus it is redundant. You did a pretty good job btw.
-
@CodeMasterAlex if you declare rating as rating = "", then it won't be null. Also, some teachers require that stupid comment, I've lost points when I left it off.
-
@iam13islucky I know that. In this case it is fine to declare them as an empty string. In many cases, like when calling a method that has a string argument, it can be valid to pass null to indicate that some value is not known. If in that method you want to compare some string value against a passed in argument you can avoid a null check in that way.
-
peterzig2698yMore and more girls coding in Java, I'm gonna be ios so ladies we can be together ios and Android dev couple hahaha
-
Wish I could find a girl who actually codes lol
There is a huge sausage party going on right now at my uni -
peterzig2698y@SirWindfield on mine Uni too but i was on Java workshops and four girls with better skills than me came with bfs haha
-
Congrats!!
One suggestion for the future- more of an "extra credit" project- make the rating an enumeration defined as excellent, good and poor, each being constructed with the message you print out.
There are different ways to convert the string value passed in by the user to be an enum.
By doing this, you can easily add new types of ratings and messages without editing the business logic in the method. Also the code becomes really simple to read and understand- input, find rating, print rating message. Lots of ifs get a little overwhelming. -
Good job! My suggestion: rethink those comments. If you declared a variable called raise, you don't need a comment explaining what it is. However if there's logic that needs explanation (and you should try to have as little as possible of that) then you can think about commenting. Always try to make the code speak for itself, try to make it read like a book.
-
@brainlessdev it looks like an early class on the curriculum, and many require excessive comments for full points. Excessive never loses points, fewer does
-
@iam13islucky Well that sucks! Comments should be used as little as possible and only when it's critical.
-
@xenonth Meant to write learning Java, phone felt like I meant Javascript, bad tag ensued.
Related Rants
-
hashit6Substitute Teacher who apparently majors in Java sees my copy. T - Your programs are incomplete M - You mean ?...
-
BillLumbergh13The worst rejection in my case is being qualified for the jobs I get offers for, but not being able to work fu...
-
nofckingcluedev6Working with a team of 5 for a college project. Told them how to use GitHub. Guess what. Fuck you and fuck Git...
!rant
I managed to do a chunk of programming in class today without my partner to hold my hand through it. It may be simple, but I am proud of it nonetheless.
undefined
college sucks
i'm an idiot
but a humble idiot
learning javascript