Results 1 to 15 of 15
  1. #1
    Ling Nl is offline Member
    Join Date
    May 2014
    Posts
    6
    Rep Power
    0

    Default Can help me solve this question ? thx

    my question are :

    You also need to write a BossEmployeeDemo class that contains a main() method. The main method for this class should:
    1. create a single instance of the Boss class,
    2. call the staffUp method on the Boss object
    - ask user to input Employee name and ID
    3. call the list method on the Boss object
    4. Be sure that you also invoke appropriate methods in Employee class when you need to hire a staff.


    Java Code:
    import java.util.Scanner;
    
    public class BossEmployeeDemo
    {
    public static void main(String[] args)
       {
    
    
          System.out.println (" Welocome To ChiaLimNeo Company " ) ;
          System.out.println(" ");
          System.out.println ("--------------------------------------------");
    
    
          Scanner input = new Scanner(System.in);
    
          int ID;
          String name ;
    
    
          Boss A =new Boss();
          Employees[]employeesList = new Employees[10]; //array to store number of employee
             for(int i= 0; i < employeesList.length;i++)   
             {
                employeesList[i] = new Employee();
                 System.out.println("Please enter ID     : ");  
                 employeesList[i].setID(input.nextInt());
                 System.out.println();
    until here... i don't know how to answer the question....please help me ...thanks

    [/B]
    Last edited by Ling Nl; 05-23-2014 at 03:14 PM. Reason: added [code] ... [/code] tags

  2. #2
    kneitzel is offline Senior Member
    Join Date
    Feb 2014
    Posts
    447
    Rep Power
    1

    Default Re: Can help me solve this question ? thx

    Can you give more details about the problems that you are facing and where you need help? At least I will not check everything just to see what is missing and then start guessing what information might help you.

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,367
    Rep Power
    6

    Default Re: Can help me solve this question ? thx

    You refuse to say what your problem actually is, you're now dumping a homework assignment. Let me guess: it's "I don't know how to do this" ?

    You're already going wrong in #1.

    Asked: 1.create a single instance of the Boss class
    What you do: create an array which can hold a String
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #4
    Ling Nl is offline Member
    Join Date
    May 2014
    Posts
    6
    Rep Power
    0

    Default Re: Can help me solve this question ? thx

    the error :

    ----jGRASP exec: javac -g BossEmployeeDemo.java

    BossEmployeeDemo.java:25: error: constructor Employee in class Employee cannot be applied to given types;
    employeesList[i] = new Employee();
    ^
    required: int,String
    found: no arguments
    reason: actual and formal argument lists differ in length
    1 error

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: Can help me solve this question ? thx

    Let's break this down.

    1.create a single instance of the Boss class,

    Java Code:
    String[]Boss=new String[1];
    This is not doing what the requirement has asked.
    This is creating an array of String of length 1.
    It is not creating and instance of the Boss class.

    And from that point on you're lost.

    So get part 1 correct first.
    You have a Boss class (you posted it above), so create an instance of it.
    Your notes should tell you how to do that.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  6. #6
    Ling Nl is offline Member
    Join Date
    May 2014
    Posts
    6
    Rep Power
    0

    Default Re: Can help me solve this question ? thx

    Quote Originally Posted by Tolls View Post
    Let's break this down.

    1.create a single instance of the Boss class,

    Java Code:
    String[]Boss=new String[1];
    This is not doing what the requirement has asked.
    This is creating an array of String of length 1.
    It is not creating and instance of the Boss class.

    And from that point on you're lost.

    So get part 1 correct first.
    You have a Boss class (you posted it above), so create an instance of it.
    Your notes should tell you how to do that.

    en .... so i want to change Boss A = new Boss (); ?

  7. #7
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,367
    Rep Power
    6

    Default Re: Can help me solve this question ? thx

    Perhaps in stead of just trying stuff, read the chapters in your study material again. You -have- study material right? A book preferably.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  8. #8
    kneitzel is offline Senior Member
    Join Date
    Feb 2014
    Posts
    447
    Rep Power
    1

    Default Re: Can help me solve this question ? thx

    And the code is removed out of the thread so I cannot copy & paste from there.

    But the error message when you tried to create a Boss instance simply tries to tell you that you didn't give any parameters to the constructor. But the only constructor requires a string and an int.

    So instead of first creating a new instance and then asking for input, you could first ask for input, store it in local variables and then create the new instance and hand over the variables.

    Konrad

  9. #9
    Ling Nl is offline Member
    Join Date
    May 2014
    Posts
    6
    Rep Power
    0

    Default Re: Can help me solve this question ? thx

    Quote Originally Posted by kneitzel View Post
    And the code is removed out of the thread so I cannot copy & paste from there.

    But the error message when you tried to create a Boss instance simply tries to tell you that you didn't give any parameters to the constructor. But the only constructor requires a string and an int.

    So instead of first creating a new instance and then asking for input, you could first ask for input, store it in local variables and then create the new instance and hand over the variables.

    Konrad

    sorry , i adjust the question ....because my question are too long


    now i change to this Boss A =new Boss(name);



    but the error still have :

    ----jGRASP exec: javac -g BossEmployeeDemo.java

    BossEmployeeDemo.java:21: error: cannot find symbol
    Employees[]employeesList = new Employees[10]; //array to store number of employee
    ^
    symbol: class Employees
    location: class BossEmployeeDemo
    BossEmployeeDemo.java:21: error: cannot find symbol
    Employees[]employeesList = new Employees[10]; //array to store number of employee
    ^
    symbol: class Employees
    location: class BossEmployeeDemo
    BossEmployeeDemo.java:24: error: constructor Employee in class Employee cannot be applied to given types;
    employeesList[i] = new Employee();
    ^
    required: int,String
    found: no arguments
    reason: actual and formal argument lists differ in length
    3 errors
    Last edited by Ling Nl; 05-23-2014 at 01:47 PM.

  10. #10
    kneitzel is offline Senior Member
    Join Date
    Feb 2014
    Posts
    447
    Rep Power
    1

    Default Re: Can help me solve this question ? thx

    Long questions are ok as long as nobody complains.

    And the main rule in my eyes is: To much code is much better than to less code. It is quite easy to skip over code if required so at least I do not care if there is some more code.

    But now I fear that the thread will by a spam thread :( A shame that this happens so often ...

    Konrad

  11. #11
    Ling Nl is offline Member
    Join Date
    May 2014
    Posts
    6
    Rep Power
    0

    Default Re: Can help me solve this question ? thx

    Quote Originally Posted by kneitzel View Post
    Long questions are ok as long as nobody complains.

    And the main rule in my eyes is: To much code is much better than to less code. It is quite easy to skip over code if required so at least I do not care if there is some more code.

    But now I fear that the thread will by a spam thread :( A shame that this happens so often ...

    Konrad
    all the coding are related to the question

  12. #12
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,367
    Rep Power
    6

    Default Re: Can help me solve this question ? thx

    Daily, actually. And daily our valiant moderators hack them to pieces.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  13. #13
    Ling Nl is offline Member
    Join Date
    May 2014
    Posts
    6
    Rep Power
    0

    Default Re: Can help me solve this question ? thx

    so any brother or sister can help me to solve my question ?
    because the coding really made me confuses...

  14. #14
    kneitzel is offline Senior Member
    Join Date
    Feb 2014
    Posts
    447
    Rep Power
    1

    Default Re: Can help me solve this question ? thx

    if your class has the name Employee then you cannot refer to it through Employees. The compiler tells you, that this is an unknown Symbol.

    And again: when you do not provide an Constructor without arguments, then you cannot create a new instance without arguments. (Only exception: if there is no constructor, java includes a default one.)

  15. #15
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: Can help me solve this question ? thx

    Also, from what I can remember of your requirements, you are not supposed to be creating an array of Employee objects, but you;re supposed to be getting them from the Boss object.

    Just step through the requirements, one at a time.
    You;re making the classic mistake of trying to write all your requirements in one go, and making a hash of it.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 2
    Last Post: 03-20-2014, 05:06 PM
  2. How do I solve this?
    By wiking in forum New To Java
    Replies: 10
    Last Post: 04-28-2013, 12:13 AM
  3. How to solve this :
    By xp_vista007 in forum New To Java
    Replies: 5
    Last Post: 03-24-2011, 08:19 PM
  4. Please help me solve them
    By quangtrung89 in forum New To Java
    Replies: 2
    Last Post: 11-26-2009, 11:08 PM
  5. PLS PLS PLS PLS solve this
    By unagie in forum New To Java
    Replies: 10
    Last Post: 07-11-2009, 10:10 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
  •