Results 1 to 6 of 6

Thread: Creating object and server prices in JAVA

  1. #1
    Join Date
    Aug 2009
    Posts
    56

    Creating object and server prices in JAVA

    I want to create a class type (Price) with three attributes (departure, arrival, price) to model a ticket booth. I must also create a Server class that stores data such as prizes (with the aid of an array of type money). The user must enter the On arrival and departure and the class ticket booth must fetch prices in the table priceof the Server class. Can anyone help me how to create such kind of class?

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    Re: Creating object and server prices in JAVA

    Rather than ultra-simple, I suggest you just use a Map to store with prices as the key string concatenation "start" and "arrival". Or, as a map with key "start" as a value and a second map with key as "arrival" as a value and price.

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Creating object and server prices in JAVA

    The map does not have multiple identical keys, therefore the validity of your solution depends on what he wants to save it. Also the 1st solution makes it difficult to search.

    A solution that works on at once, but not necessarily optimized to be stupid in a list all your items and price go in ensuring that the criteria are.

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    Re: Creating object and server prices in JAVA

    I thought a key style string concatenation departure and arrival.

    Examples of keys:

    "Paris-Rouen"
    "Lille-Calais"

    And as a value priced digital form.

  5. #5
    Join Date
    Aug 2009
    Posts
    56

    Re: Creating object and server prices in JAVA

    Thank you for your explanations, what I want is basic, I will explain:
    I want to create an object type Price

    public class Price {
    String departure;
    String arrival;
    double price;
    }

    the class server and create an array of type Price
    Price [] tablePrice;
    but after I blocked I can not see how the rest.

    I must also create another class of Tickets that must be called to the class server.

  6. #6
    Join Date
    Feb 2009
    Posts
    96

    Re: Creating object and server prices in JAVA

    your question isn't so easy to understand....

    basically if I understand it correctly you need 2 classes

    class 1 is an object class
    class 2 is your main class

    class 1 contains data for the object such as arrival, departure, and monies involved

    class 2 uses said information to retrieve the data from the created object

    now with that said making an object with a departure and arrival times along with prices makes no sense to me -- seems like you should be placing cities in the arrival/departure area
    anyways you'll need to create a loop to check to see if the price matches what you have -- and in order to do this your loop needs to be set up something like

    for(int i = 3; i<something.length; i++)
    method here

Similar Threads

  1. Replies: 6
    Last Post: 06-06-2011, 01:34 AM
  2. How big is an Object in Java? Why Java neglects sizeof?
    By KALINDA in forum Software Development
    Replies: 4
    Last Post: 10-11-2009, 03:19 AM
  3. Creating a Vector Object in Java
    By Coldman in forum Software Development
    Replies: 4
    Last Post: 04-03-2009, 02:45 PM
  4. Object test = new Object() <-- Java, best way in C++
    By ADISH in forum Software Development
    Replies: 3
    Last Post: 25-10-2008, 02:32 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,169,816.33452 seconds with 16 queries