-
Question - Help needed, please.
I am trying to write a program that stores information about users. It will have thier name, a salary, vacation and sick days. I have using class inheritance for some of the information (i.e. name).
Here is where I am stuck (and perhaps I am doing it all wrong, not really sure). I want to be able to prompt the user to input a employee ID number, I want the employee ID to match with the static infomation I have already put in, so I can display information about the person they want to know about. I also want to be able to add new names, and modify certain data on existing names (i.e. Vacation days, sick daya and salary.)
can anyone tell me a way to get a person to input an ID number that can be converted or matched with all the information on a single user?
Does this make sense at all? Some, any and all adivce as well as help would be greatly appreciated.
Thanks,
DD
"aut vincere, aut mori"
-
How are you storing the data about your employees? The best way (IMHO) is an employee object with an id, name, etc... variables. Assuming there are not thousands of employees in your database, you should be able to create an array of these objects to store all the employees.
Code:
Employee[] my_employees = new Employee[no_employees];
Once the user has input the id, you can then loop through the array, checking the id value until you find the correct object with which you can access its variables.
If you'd like more control over the number of employees and modifying them it might be best to use some other data structure (like a vector) other than an array. Post some of your code if you'd like more specifics.
Cheers,
Tom.
-
Thanks
Thanks for the reply,
I think the array is what I needed. I just had not figured out how to work it, your answer I think is leading me in the right direction. I will continue to muddle through on this. Thanks again for the answer, it really helped.
DD
"aut vincere, aut mori"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks