Liutauras Vilda

Marshal
+ Follow
since Nov 12, 2014
Liutauras likes ...
BSD
software developer, moderator at coderanch, a father, husband and nintendo switch owner
London, United Kingdom
Cows and Likes
Cows
Total received
411
In last 30 days
10
Total given
1228
Likes
Total received
1234
Received in last 30 days
24
Total given
1113
Given in last 30 days
28
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Liutauras Vilda

Matt Wong wrote:breadth... never heared this word.


Off-topic. Never heard Edsger W. Dijkstra?
1 day ago

Maurizio Gasparro wrote:Also, I feel that sometimes it describes things the other way round, for example when she says: "Call a getData() method three times." And then: "Prompt the user to input data for the fields...".


Just to be slightly on the assignment's side... This is not what assignment requirements say. So you copied/pasted and interpreted (*misinterpreted*) your way. That is a very common thing.


Requirements say:

Call a getData() method three times. Within the method, prompt a user for values for each field for a Lease...


That is very different from what you said.

True story:
I also had in university an assignment similar to that. I think it was from JavaScript. Basically we were given instructions - they were very simple, primitive (and that was on purpose, read further..), and everybody laughed how simply assignment going to be, some of the students packed right away and went home happy. However, lecturer warned, that 100% marks will be given for those who will follow requirements exactly (so long as even smallest tiny piece of details are followed), and will be marked down significantly for shifting from them.

After assignment was finished and marks were distributed, lecturer provided statistics across the years for this very exercise, only up to 10% of people were able to follow requirements (*even tho lecturer made very clear what is going to be tested in this assignment*).

Our group weren't exception. 10/90.

I'll check whether I can publish these requirements (and not to breach anything) just for everybody to see how easy it was, or more precisely, how such an easy instructions were over complicated, misinterpreted, decisions to improvise were made and so on and so forth, so marks were not that good as everybody expected. It was one of my favourite assignments - I've learned from it a lot.
1 day ago
@Randy Tong

Yeah. Maybe admins could have asked you to elaborate more, so you could have edited your correct answer by adding some reasoning behind, but they didn't. Anyway, they did provide the reason(s) why your answer was down-voted and possibly deleted initially.

The best next step you can do, is to implement such reasoning in your answers and see how things go then. If you ask me, the reason you have been given makes perfect sense to me. That is something we all supposed to have in mind when provide answers, not just on forums.

CodeRanch actually is exactly opposite, we mostly discuss the reasons behind, so the user could assemble the rationale him/her-self and possibly come up with the problem solution. Providing complete solutions would result in some similar actions taken by the moderators.
2 days ago
Welcome to the Ranch, you are new here

Campbell is right, code isn't readable, method does more than 1 thing, it has more than 1 exit point (3 return statements), confusing variable names.

Why method returns Rooms (plural)?

You have 4 nested constructs. When you find that you are nesting something, extract to a method, so there supposed to be at least 4 methods, and probably more.

Could you describe in English your algorithm?
2 days ago

Sesame Street wrote:“They were created to teach preschoolers that people can be good friends with those who are very different from themselves. Even though they are identified as male characters and possess many human traits and characteristics (as most Sesame Street Muppets do), they remain puppets, and do not have a sexual orientation.”


I don't know if that's because I born and grew up in a small city (15.000 people), or the specifics of my homeland, or the time when I grew up (I'm only 34), but until 16 years old or so (I think) I've never heard even the word "gay". And of course didn't know meaning either. So to come up with such sexual orientation thing would have been even impossible.
2 days ago

Jan de Boer wrote:Not to you, but to the manager of the company I am leaving. If she asks.


This is exactly what I meant.

Jan de Boer wrote:(If you're not interested just don't read.)


I read and replied, but thanks for making such option available  
3 days ago

Jan de Boer wrote:I have got a new job.


Congratulations, Jan!

Jan de Boer wrote:I now wonder if I should tell this is one of the reasons I am leaving.


Forget! Don't you have anything more important to do...

You better tell us about the new job, that should be the exiting news, not the crap from the past.

3 days ago
Introduction to Algorithms By Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, Clifford Stein
3 days ago

Bart Wtoras wrote:This is a 100% accurate description of the requirements:

version 1 wrote:
Implement given method, so it would return the searchable element from the given array in case it is found, otherwise throw an exception. 


So your method doesn't do that.
3 days ago
OP's lately posted code contains bug I just mentioned. Well, OP needs to tell exact requirements, otherwise there is a risk to mislead.
3 days ago

Bart Wtoras wrote:What is important in this task is throwing an Exception in case when nothing is found in an array.


Well, important is to accomplish the task as required, not just implement the parts which are important. So I suggest to consult with someone who gave this task to you in order to understand requirements well.

Now, whether the program is correct..

Bart Wtoras wrote:I have found a solution, throw new Exception solved my problem.


In order to verify that your solution is indeed correct, or at least to have a good amount of evidence of that, or more precicely - to not find the case on which your program fails, you need to test it against various inputs. You don't need to use modern technologies for testing, you can simply try to execute your program against several of different kind inputs, i.e.: negative number, positive number, zero (which is a number too).

What do you think would happen if I were try to invoke:
?

That supposed to give you a good idea whether your program is correct or still needs some coding. In general you are on the good track
3 days ago
Please explain why do you assign 1 to a result (line 13) and later return that? That is not what you confirmed as wanted functionality.
3 days ago
Welcome to the Ranch.

That seems to be a fairly simple task, however, instructions are well confusing I'd say, at least how they are written/expressed currently.

Reasons:
Such method name "elementExists" I'd expect to have a return type boolean in the first place, that's not the case, so it is an int.

instructions wrote:Complete the method signature with information that it can return the Exception.


Neither return type, nor what exception method possibly throws are part of method signature. So this quote doesn't make sense at all. Might be the problem in translation. And I'm very doubted you'd ever want to return exception from such method in general.

So what I think this task is asking you are one of these two:

version 1 wrote:Implement given method, so it would return the searchable element from the given array in case it is found, otherwise throw an exception.


version 2 wrote:Implement given method, so it would return the searchable element's index (first) from the given array in case it is found, otherwise throw an exception.


My wording also might be a bit off in terms of English, but at least a bit clearer in terms of Java terminology.

Do you have an ability to verify requirements with somebody?
4 days ago
Authors, nice to see you here - welcome and have a great promo week!