d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Fg For Solution > Java
Add Reply New Topic New Poll
Member
Posts: 3,261
Joined: Apr 15 2012
Gold: 1,410.00
May 25 2017 05:55pm
Hey there JSP community!
Im currently in my second year studying information technology and part of my "Programming 1" course I have a current assessment I need help with :wallbash:
Ive been stuck on it and cant figure out how to go about it.
It is almost done and is due in 3 days so I still have a bit of time, BUT I am aiming for a high mark!
I have emailed my teacher and ... no response
So I thought I would offer 100fg for a quick response that leads to a solution!



I can send the rest of code through PM if need be :)
Thank you all!

Notes:
getEId() is a get method from class employee... if that helps at all :P

cfound is a part of array:
ArrayList<Employee> employees;
Employee cfound;


This post was edited by SonOfZeus on May 25 2017 06:17pm
Member
Posts: 12,080
Joined: May 3 2017
Gold: Locked
Trader: Scammer
May 25 2017 06:28pm
Sounds like strings are not valid inputs for compile error #1. Should be easy fix.


int is a primitive value. It is not an object and has no methods so you cant do m.equalsignorecase

This post was edited by Zekdawg on May 25 2017 06:33pm
Member
Posts: 2,621
Joined: Aug 11 2013
Gold: 0.00
May 25 2017 06:34pm
You deserve a 0 for naming your objects and data types 1 letter

for the answer you're looking for:
Can't use an int, either use an object or a string (cannot guarrantee a string will work!)
Member
Posts: 27,177
Joined: Mar 27 2008
Gold: 445.00
May 25 2017 07:57pm
Quote (Zekdawg @ May 25 2017 08:28pm)
Sounds like strings are not valid inputs for compile error #1. Should be easy fix.


int is a primitive value. It is not an object and has no methods so you cant do m.equalsignorecase


Zekdawg got it.

Basically you are passing foundEmployee and the method is expecting an integer. From the method it is safe to assume you are passing a string.
Member
Posts: 8
Joined: May 26 2017
Gold: 650.00
May 31 2017 02:16pm
Looks like there's a few things going on, some pointers (ha!):

1. If your IDE has the ability to display line numbers, do that in the future. It makes referencing lines here much easier.

2. You're getting the employee identifier from a text box. Later on it seems like your employee IDs are numeric - make sure you're validating the input so non-numeric values aren't entered in the textbox. IF this should actually be an employee name or something, you'll need to convert it to the integer identifier before calling searchByEmployeeId.

3. searchByEmployeeId takes an interger, and you're passing a string. That's compile error #1.

4. For compile error #2, you're trying to invoke a string method on an integer. If you want to compare integers, you can simply use ==.

5. As others said, don't name variables with only one letter. Your future self and future assistants will greatly appreciate it.

6. Comment what you're doing in the larger two blocks in the middle of your image there. It'll help you reason through issues like this if you speak it (or type it) out.

HTH!
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll