James Leon

Greenhorn
+ Follow
since Jan 26, 2016
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by James Leon

I started Java recently and been learning about sets. I thought I understood the basics of sets, but I do not think I do It is for an assignment which is why I don't want people to just give me the answer, but rather point me in the right direction. I looked through all my books to no avail and my tutor is taking too long to reply to my e-mail.

There is an Employee Class, which has three instant variables of type String: first name, second name, and emplyoeeNumber and an instant variable of type int called sales.

I have to create a new class called Payroll and declare a private instant variable called employeeSet which is capable of referencing Employee objects that are to be held in alphanumeric order of their employee numbers, and make it so that employeeSet is assigned a suitable empty set object when a new instance of Payroll is created



I then have to write a public instance method in the PayRoll class called enrollEmployee() which takes a string representation of an employee number as its argument and returns no value. The method should create an instance of Employee and then add it to the set referenced by the instance variable employeeSet.

All I got so far is this:



I just have no idea on what I am doing. I don't even know if the small amount I have done is right. I know it is simple, but I keep on over thinking things. Maybe it will make more sense if I have a rest, but haven't really got time to rest.
8 years ago

J. Kevin Robbins wrote:Do you know how to use a for loop?



The first parameter is your "counter". See if you can figure out how to make it loop.

[edit] This might be clearer if I had said:



Thank you so much!! Managed to get it working now
8 years ago
I am brand new to Java and it is my first programming language, but I'm struggling to understand loops. As part of the assignment I am doing, I have been given some code that I have to edit/add too depending on what the question asks. The question that I am stuck on is:

"Write an exercise() method in the RestrictedHoverFrog class that implements the following behaviour:

– If the second argument to the receiver has the value true, attempt to move the receiver left, then right, then right again, then left again – with this sequence of moves repeating according to the number of times specified by the first argument.

– If the second argument to the receiver has the value false, attempt to move the receiver right, then left, then left again, then right again – with this sequence of moves repeating according to the number of times specified by the first argument."

So far I got the following code. I know it's wrong and that it doesn't repeat the sequence, but I don't know how I can get it to repeat the sequence depending on the number of times specified by the first argument.




Any help will be really appreciated please
8 years ago