Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Optimum solution for objects

  1. #1
    Junior Member
    Join Date
    Aug 2014
    Posts
    29
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Optimum solution for objects

    Hi all,
    Sorry for the title, but i couldnt think of a way to describe my problem.

    I am creating an apointment application. This programm will have the ability to book apointments for a number of different services, such as doctors, hairdressers, teachers etc for a number of cities.
    These information will be placed on a combo box and ideally i would like to provide only the options available acording to the choices made so far.
    So, for example we have
    A Pediatric in London
    A Vet in London
    A Sergeon in Berlin
    A Barber in Berlin
    A Heardresser in Rome
    A Programmer teacher in London
    An English teacher in Rome

    My thinking is that the user choses the city, for example London, then there will be a type of service combo box. In this case (of London) it will hold Doctors and Teachers. If Doctors is chosen, the next field will hold the available Medical specialty, i.e. Pediatrics and Vets and according to that choice the apropriate doctor will pop up.

    My problem is not how to programm that. i havent got there yet.
    My problem is how to design it! I am thinking that each individual will be an object. each having the same fields, city, type of service etc. But in such a way i am not sure how i can manage to get all the appropriate information in order to poppulate the combo boxes.
    I would have to search all the objects for each combo box?
    From a rough testing i did, i think i could easily get all the individuals that resign in London, but that would give me two records for the doctors(for example).

    ANY idea will be highly appreciated, since i am stuck right now!

    Thanks in advance, ilias


  2. #2
    Senior Member
    Join Date
    Jul 2013
    Location
    Europe
    Posts
    666
    Thanks
    0
    Thanked 121 Times in 105 Posts

    Default Re: Optimum solution for objects

    If you force the user to go the way: City -> Job -> Speciality -> Person
    the it is a simple tree structure.

    The root node has a list of all cities as its children, each city has a list of jobs as their children, each job has a list of specialities as their children and each speciality has a list of people as their children.
    You could even generate the number of combo boxes on the fly to match the depth of the tree. This way you could have jobs with no specialities or certain people who are listed but have no job.

  3. #3
    Junior Member
    Join Date
    Aug 2014
    Posts
    29
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: Optimum solution for objects

    hm... trees?!
    never used them before.
    Can i use the tree nodes on an object?
    If i got it right, many of the data will be repeated for each city.
    for example having a pediatric in London and in Berlin would look something like that:
    London Berlin
    | \ |
    Doctor ..... Doctor
    | |
    Pediatric Pediatric
    | |
    Dr A Dr B
    In this case both "Doctor" and "Pediatric" are repeated for both cities. Did i understand this right?

    i will have to create a new tree, having 2 attributes, its name and its parent name.
    So, it will be something like
    Class Tree(){....}
     
    ArrayList<Tree> tree;
    tree.add("London");
    tree.add("Berlin");
    tree.add("Doctor","London");
    tree.add("Doctor","Berlin");
    but how would i add a pediatric to the Londons doctor branch and not to the berlin branch?

    Could you give me some sample code please?
    Thanks for the info, at least i have something else to work with now.
    ilias

Similar Threads

  1. SOLUTION
    By tefo in forum What's Wrong With My Code?
    Replies: 2
    Last Post: September 16th, 2014, 09:41 PM
  2. HR Solution
    By sharif_jp in forum What's Wrong With My Code?
    Replies: 1
    Last Post: June 28th, 2014, 07:27 AM
  3. Need help to implement a solution with ArrayLists & Objects
    By IanSawyer in forum Java Theory & Questions
    Replies: 1
    Last Post: March 20th, 2012, 06:01 PM
  4. Solution
    By Suresh.athi in forum The Cafe
    Replies: 1
    Last Post: January 19th, 2012, 08:46 AM
  5. Please help me with the solution
    By abhyudayaupadhyay in forum What's Wrong With My Code?
    Replies: 0
    Last Post: July 6th, 2011, 03:21 PM