• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Beginner programmer with some errors in my code.

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am working on my assignment which is to create an employee database, the below is what i have so far. and i am getting the following errors: line 54 "firstname can not be resolved to a variable"  line 66,68-71 "employee cannot be resolved to a variable"   line 68 "first name cannot be resolved to a variable   ....  please help..

Any tips in general on the assignment will be greatly appreciated. This is my first coding and it is very hard for me.


here are the assignment instructions
1. An Employee class that contains data about individual employees
a. Fields (all Strings): Last name, first name, department, and job
b. Methods:
i. Set: One “set” method (e.g., setLastName) for each field, which accepts a String object as a parameter and sets the field to the same value as that String
ii. Get: One “get” method (e.g., getLastName) for each field, which returns a String object and leaves the field unchanged
2. An EDA class that maintains records of employees:
a. Fields:
i. an array of Employee objects (initial size set to 100)
ii. a counter (type int) for the current Employee count
b. Methods:
i. Modify: Requires a field name, a match value, and a new value. For any Employee objects whose field matches the match value, the field will be changed to the new value using the appropriate set method
ii. Add (full): Requires four Strings, which will be used to create a new Employee object at the lowest-index unused array entry. Creation will be accomplished via a constructor method. Counter will be incremented.
1. Add (partial 1): Create Employee object using only last name & first name. Department and job will be set to “Unassigned”. Counter will be incremented.
2. Add (partial 2): Create Employee object using only last name, first name, & department. Job will be set to “Unassigned”. Counter will be incremented.
iii. Delete: Requires four Strings, which will be used to identify the correct Employee object. Any Employee objects for which all fields match these four fields will be deleted. The array will be compressed and the counter will be decremented.
iv. Read: Requires a field name and a match value. For any Employee objects whose field matches the match value, the full set of four fields will be displayed on a new line on the console.
c. Inputs:
i. All inputs and output should take place using the Eclipse console
ii. Input format: Words in a multi-word input should be separated by a single space character and be on a single line (i.e., only one Enter keystroke per input)
iii. Inputs should be read using a Scanner object
iv. Inputs should support using a wildcard character “*” as a match value (which will in effect display all Employee records)


 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This has to do with the "scope" of a name in your program. Scope determines the visibility of the name and where it can be legally used. In your case, the "name cannot be resolved" error occurs because of your use of a name that is not in scope/visible from that part of the program.

It's like referring to "Main Street" without saying what city you're in.

One thing you have going on that is not usuall practice is that you have placed the code for the Employee class inside the main method. That means that the Employee class will only exist and mean something inside the main method. Anywhere else, the name Employee is "undefined". You want to put that code outside of the EDA class instead. That still won't resolve the original problem though. One thing you can do to resolve that is to declare those names as local variables.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic