Results 1 to 16 of 16
  1. #1
    Ramkiller1 is offline Member
    Join Date
    Feb 2013
    Posts
    10
    Rep Power
    0

    Default Need help With program

    Sorry , I am not good at java programming. I have a main class that has a menu system that loops, if 1 is pressed it is passed to another class which then passes the information to another class. So we have 1 main class (MAIN), one second class(SECOND) and 1 third class (THIRD). I have an array in the THIRD that the information that MAIN sends go into. When the loop in MAIN is started over, the program goes to THIRD and overwrite what is made in the array . Can someone please tell me how to fix this

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    7

    Default Re: Need help With program

    Have a pointer in THIRD that tells you where to insert into your array. I reckon you always insert at array[0].

    It's hard helping without seeing your code.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  3. #3
    Ramkiller1 is offline Member
    Join Date
    Feb 2013
    Posts
    10
    Rep Power
    0

    Default Re: Need help With program

    [edited out]
    Last edited by Ramkiller1; 02-20-2013 at 04:05 PM.

  4. #4
    Ramkiller1 is offline Member
    Join Date
    Feb 2013
    Posts
    10
    Rep Power
    0

    Default Re: Need help With program

    This is what I am trying to get done but having a hard time (yes i bet its easy for some of you). lol

  5. #5
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    7

    Default Re: Need help With program

    Aha, your Company class only knows one Employee, which is overwritten every time. You need a List of Employees in Company.
    Look at the UML: Company has an Employee array, which you have forgotten.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  6. #6
    Ramkiller1 is offline Member
    Join Date
    Feb 2013
    Posts
    10
    Rep Power
    0

    Default Re: Need help With program

    hmm so make the array in company instead , hmm and use get methods from employee to put the information in the array?

  7. #7
    Ramkiller1 is offline Member
    Join Date
    Feb 2013
    Posts
    10
    Rep Power
    0

    Default Re: Need help With program

    Quote Originally Posted by PhHein View Post
    Aha, your Company class only knows one Employee, which is overwritten every time. You need a List of Employees in Company.
    Look at the UML: Company has an Employee array, which you have forgotten.
    Ok changing the position of the array helps me now thanks. Any other suggestions you can see I am doing wrongly?

  8. #8
    Ramkiller1 is offline Member
    Join Date
    Feb 2013
    Posts
    10
    Rep Power
    0

    Default Re: Need help With program

    Can you tell me how do I get a return type of an object . On the sheet that has company methods, the return type of getemployee is employee

  9. #9
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    7

    Default Re: Need help With program

    Defining Methods (The Java™ Tutorials > Learning the Java Language > Classes and Objects)
    Java Code:
    public Employee getEmployee(int employeeID){
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  10. #10
    Ramkiller1 is offline Member
    Join Date
    Feb 2013
    Posts
    10
    Rep Power
    0

    Default Re: Need help With program

    Quote Originally Posted by PhHein View Post
    Defining Methods (The Java™ Tutorials > Learning the Java Language > Classes and Objects)
    Java Code:
    public Employee getEmployee(int employeeID){
    How is it going to find an employee object with the ID. Sample code will do fine

  11. #11
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    7

    Default Re: Need help With program

    Loop over the array and compare IDs.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  12. #12
    Ramkiller1 is offline Member
    Join Date
    Feb 2013
    Posts
    10
    Rep Power
    0

    Default Re: Need help With program

    Ok, thanks for the info 1 last question, I would think the get Employee would return a string to the company class, how do i make the statement to return it

  13. #13
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    7

    Default Re: Need help With program

    Look at table 4! getEmployee returns an Employee. And it's returned to whatever object called it.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  14. #14
    Ramkiller1 is offline Member
    Join Date
    Feb 2013
    Posts
    10
    Rep Power
    0

    Default Re: Need help With program

    Yea, thats the point, I dont understand, I dont understand what would come out when returned thus I dont no what kinda of return statement to make.

  15. #15
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    7

    Default Re: Need help With program

    return employee;
    Did you read the method tutorial I've posted before?
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  16. #16
    Ramkiller1 is offline Member
    Join Date
    Feb 2013
    Posts
    10
    Rep Power
    0

    Default Re: Need help With program

    Quote Originally Posted by PhHein View Post
    return employee;
    Did you read the method tutorial I've posted before?

    yes some things were like greek like Passing Reference Data Type Arguments and the first object page was not fully clear for me
    Last edited by Ramkiller1; 02-20-2013 at 03:47 PM.

Similar Threads

  1. Replies: 4
    Last Post: 11-21-2012, 02:19 PM
  2. Replies: 2
    Last Post: 04-02-2011, 01:57 PM
  3. changing my program to array working program
    By Chewart in forum New To Java
    Replies: 39
    Last Post: 11-18-2009, 07:53 PM
  4. Replies: 0
    Last Post: 04-04-2008, 03:40 PM
  5. Replies: 0
    Last Post: 10-04-2007, 10:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •