Results 1 to 5 of 5

Thread: Help Vector

  1. #1
    nikosv is offline Member
    Join Date
    Dec 2010
    Posts
    8
    Rep Power
    0

    Default Help Vector

    Hello i am new to java
    I want to develop a software application for salary management.
    How to add and to substract Ergazomenos (Employee in Greek) in the total Ergazomenos in which he is Proistamenos( Boss in Greek)?

    Proistamenos extends Ergazomenos
    In main i wrote this:

    public static void main(String[] args) {
    Ergazomenos e1=new Ergazomenos("n","v",2000f, 200f, new Date(12,3, 1989),new Date(12,3, 1989), 40,new Date(12,3, 1989),14);

    Vector erg=new Vector();

    if(erg.contains(e1))
    erg.add(e);
    else
    System.out.print("Do nonthing");

    if(erg.contains(e1))
    erg.remove(e);


    }

  2. #2
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    Last edited by al_Marshy_1981; 12-10-2010 at 02:40 AM. Reason: cannot spell Vector anymore

  3. #3
    makpandian's Avatar
    makpandian is offline Senior Member
    Join Date
    Dec 2008
    Location
    Chennai
    Posts
    444
    Rep Power
    6

    Default

    You mentiond that you are just newbie. So better use ArrayList instead of Enumeration
    Mak
    (Living @ Virtual World)

  4. #4
    nikosv is offline Member
    Join Date
    Dec 2010
    Posts
    8
    Rep Power
    0

    Default

    I have a question. The object erg is from the class Ergazomenos and the object proist is from the class Proistamenos. Do i have to write
    ArrayList erg=new ArrayList();
    ArrayList proist=new ArrayList(); or

    ArrayList<Ergazomenos> erg=new ArrayList<Ergazomenos>();
    ArrayList<Proistamenos> proist=new ArrayList<Proistamenos>();

    I want to copy Ergazomenos objects to Proistamenos in order to substract or to add Ergazomenos from Proistamenos


    in main i wrote this......




    Ergazomenos e1=new Ergazomenos("n","v",2000f, 200f,new Date(12,3, 1989),new Date(12,3, 1989), 40,new Date(12,3, 1989),14);
    Ergazomenos e2=new Ergazomenos("ng","gv",2000f, 200f,new Date(12,3, 1989),new Date(12,3, 1989), 40,new Date(12,3, 1989),14);

    ArrayList erg=new ArrayList();
    ArrayList proist=new ArrayList();

    erg.add(e1);


    Proistamenos p1=new Proistamenos ( "n", "h",
    44, 12, new Date(12,12,1212),
    new Date(12,3, 1989), 14, new Date(12,3, 1989), 12,
    "ionio", new Date(12,3, 1989),
    new Date(12,3, 1989), 30, 10);

    proist.add(p1);

    // Proistamenos(String onoma, String epitheto, float
    // vasikosMisthos, float Iperoria, Date imerominiaProslipsis,
    // Date imerominiaGennisis, int afm, Date imerominiaApolisis, float antimisthia,
    // String onomaTmimatos, Date ImerominaProistamenos, Date
    // ImerominiaPausisProistamenos, int numberOfErgazomenous, int epidomaThesis) {
    //



    System.out.println("Before copy second Vectors contains\n "+proist);
    proist.addAll( erg);

    // Collections.copy(proist, erg);


    // proist.addAll(erg);

    System.out.println("After copy second Vectors contains\n "+proist);




    //System.out.printf("vector contains \n\n %d\n ",erg.indexOf(e1));

    //System.out.println("e1 " + e1.toString());
    if(erg.contains(e1))
    System.out.println("true");
    erg.remove(e1);


    if(erg.contains(e1))
    System.out.println("true");

  5. #5
    makpandian's Avatar
    makpandian is offline Senior Member
    Join Date
    Dec 2008
    Location
    Chennai
    Posts
    444
    Rep Power
    6

    Default

    ArrayList erg=new ArrayList();
    ArrayList proist=new ArrayList();

    it means that you can add any object into list erg, proist.

    ArrayList<Ergazomenos> erg=new ArrayList<Ergazomenos>();
    ArrayList<Proistamenos> proist=new ArrayList<Proistamenos>();
    It means that you can add only Ergazomenos objects in list erg and you can add only Proistamenos objects in list proist.

    Hope this helps you.
    Mak
    (Living @ Virtual World)

Similar Threads

  1. Vector<vector> loop thru
    By ocean in forum New To Java
    Replies: 11
    Last Post: 11-21-2009, 02:17 PM
  2. Vector
    By sanox in forum New To Java
    Replies: 20
    Last Post: 09-01-2009, 04:21 PM
  3. Vector
    By MuslimCoder in forum Advanced Java
    Replies: 4
    Last Post: 08-06-2009, 03:44 PM
  4. Replies: 1
    Last Post: 04-06-2009, 06:45 AM
  5. Vector help
    By king_arthur in forum New To Java
    Replies: 3
    Last Post: 01-22-2008, 07: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
  •