Results 1 to 8 of 8

Thread: need help moving a program into classes

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2004
    Posts
    6

    Resolved need help moving a program into classes

    hello everyone

    how is everything going?

    i am a new user here and and was wondering if anyone could help me with a program that i am writing. i have it most of it writen its but need to put it into classes. i just started to learn java so this stuff is new to me
    if anyone can help please let me know.

    thank you

    this is the basic overveiw of the program i am trying to write
    :

    i need Create an employee class with data members:
    name, department number, employee number and salary
    Derive a class student employee from the employee class.
    student employee data members:
    grade point average & accumulated hours

    The input should include name, department number, employee number, salary, grade point average and accumulated hours.

    In addition, after all the data has been entered, i need to sort student employees by name.

    and Store the valid student employee records in an array of student employees

    also, Store the invalid student employee records in an array of student employees.
    what the program does

    Reads in name, department number, employee number, salary, grade point average and accumulated hours.

    Validate the values in a method and displays unique error messages.

    Count the number of good records, bad records and total records.

    Display the average of the salaries in the good records.

    When the user has entered 5 records, display the records in the arrays sorted by name.

    these
    Ranges:
    name 1 - 10 characters
    department number valid range : 1 -10
    employee number valid range : 1 - 100
    salary valid range : 1.0 - 999.99
    grade point range : 0.0 - 4.0
    accumulated hours: equal to or greater than zero

    i am helping out a freind that needs this program to work, i am having some trouble

    i have this program working without the use of classes and sorts so if anyone can help and would like to see my code please let me know
    any help would be apprecaited thank you
    thank you again
    Last edited by dante27; Dec 1st, 2004 at 03:52 PM.

  2. #2
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111
    Just post the code you have so far. I am sure me and many other users of this forum will help to their full potential.

    I guess you would have one central class(the employee class) and then the student employee class that extends the employee class.

    How many classes are you needing this in?
    It looks like you could have 2 or 3, not sure.
    Last edited by System_Error; Nov 22nd, 2004 at 05:41 PM.

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2004
    Posts
    6

    code

    hello thanks for the quick reply


    i need 2 classes the employye and a student employee
    i have attached the file
    let me know if you want me to post it instead of the attachment.

    and again thank you
    Attached Files Attached Files
    Last edited by dante27; Nov 22nd, 2004 at 06:45 PM.

  4. #4
    Banned debbie_82's Avatar
    Join Date
    Jan 2004
    Location
    inside a hollow void
    Posts
    104

    Here is my implementation of your program using classes.

    Attached is the whole project folder (you can import this in Eclipse)..

    if you're not using eclipse then you can just compile the source.

    Hope I answered a part of your dilemma.

    Just send me email at my gmail account if you have questions.
    [email protected]
    Attached Files Attached Files
    Last edited by debbie_82; Nov 23rd, 2004 at 08:17 PM.

  5. #5
    Banned debbie_82's Avatar
    Join Date
    Jan 2004
    Location
    inside a hollow void
    Posts
    104
    BTW...

    The classes included are:


    AppDemo - main is located here, basicall this is where processing is done.
    ConsoleInput - A class used to get the input from the console. To make encapsulate the acquisition of values... makes the code cleaner
    Employee - the superclass
    StudentEmployee - the class which extends Employee
    ValidRange - A class that just holds the valid ranges.. I just made this so as to lookup one location for all the constants needed.
    Cell - An implementation of a Singly-linked list whose first element is empty... empty so that manipulation like addition is easier.. lesser code to do.

  6. #6

    Thread Starter
    New Member
    Join Date
    Nov 2004
    Posts
    6
    hello,
    thank you for the program. it works great i do have some questions?

    i do have a some questions if you don't mind, i was wondering if there is anyway to make the program with out using the consleInput? if its possible? don't worry if its a bother. also i not really sure what exactly the code for cell does besides leave the first space empty is that mainly it?

    well i thank you again for your time


    also if anyone else has worked on this and did it a different way i would apprecaite it if you could post your code up, just because i new to java i would like to know the different ways that this can be done or approched .

    thank you

  7. #7
    Frenzied Member vbNeo's Avatar
    Join Date
    May 2002
    Location
    Jutland, Denmark
    Posts
    1,994
    If I were you I'd keep the consoleInput class as it's a good way of seperating it from the rest. Besides, it really doesn't matter if it's there or not to the user, only the programmer, in which case I don't see why it should be a problem to you...
    "Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
    - Zack de la Rocha


    Hear me roar.

  8. #8
    Banned debbie_82's Avatar
    Join Date
    Jan 2004
    Location
    inside a hollow void
    Posts
    104

    Here is an update... Employee Demo using Swing

    This is For those who want to study swing also.

    I have updated the Project I attached... and here it is.
    It's using Swing... basically it is still the same. no classes
    have been removed I just added Two:

    AppDemoGui - the gui but the process is still within AppDemo class
    IncompleteDataException - an exception when the user tries to add incomplete information. so that AppDemo will be notified about the error

    BTW... the listener for all the buttons is the AppDemo class.

    The project can be run either using the GUI or the console that's why I didn't remove the other classes

    Cell is still used since I haven't tried using LinkedList in java.util yet. . I just made one that is convenient for me. But you can have your own implementation.. the style I adopted from a code I downloaded from planet-source code.. so it all depends on how you want to code it. .. just make sure you understand and that the code works.

    Invoke the class using the java interpreter:
    to Run in Gui:
    java AppDemo

    to Run in Console same as before output:
    java AppDemo console

    As usual this project can be imported in eclipse.
    Attached Files Attached Files

Posting Permissions

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



Click Here to Expand Forum to Full Width