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?
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.
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.
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.
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.
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