Results 1 to 2 of 2
- 07-21-2011, 10:15 PM #1
Member
- Join Date
- Nov 2010
- Posts
- 40
- Rep Power
- 0
Can't create object with specified perimeters
I have this class
Im trying to create that object with specific perimeters.Java Code:package testers; public class FurnitureStore implements Comparable<FurnitureStore>{ private double price; private String address; private double distance; private String hours; public FurnitureStore(double price, String address, double distance, String hours) { super(); this.price = price; this.address = address; this.distance = distance; this.hours = hours; } public double getPrice() { return price; } public String getAddress() { return address; } public double getDistance() { return distance; } public String getHours() { return hours; } @Override public int compareTo(FurnitureStore o) { // TODO Auto-generated method stub return 0; } }
So in my other class im adding it to an array list.
Java Code:import java.util.Random; public class FurnitureClient { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub int counter = 0; String stuff = "Hello this is"+counter; Random rand = new Random(); ArrayList<FurnitureStore> fs = new ArrayList<FurnitureStore>(); fs.add(39.99, "6234 Free Street, San Antonio TX, 78250", rand.nextDouble()*2000, "8:00AM - 10:00PM");
It tells me that my perimeters are not right but they are cant seem to find what im missing
- 07-21-2011, 10:24 PM #2
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
You are just adding parameters to the list and not calling the constructor. It should look something like this
Java Code:fs.add(new FurnitureStore(/* args */);
Similar Threads
-
What is best object to create?
By lam5442 in forum New To JavaReplies: 1Last Post: 02-23-2011, 09:44 PM -
Create new Calendar object???
By aliencc in forum New To JavaReplies: 4Last Post: 01-17-2011, 01:19 PM -
Can we create object without new operator ?
By rohitjava in forum New To JavaReplies: 11Last Post: 09-08-2010, 05:26 AM -
Create object of unknown class, based on existing object
By Zack in forum New To JavaReplies: 2Last Post: 06-22-2010, 04:29 AM -
create object
By paul21 in forum New To JavaReplies: 4Last Post: 03-07-2010, 07:14 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks