hey i need help on testing a class it is confusing me on how to do it i was wondering how would i do it.
i need to create 3 objects in another classes constuctor n store them in an arraylist
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.
hey i need help on testing a class it is confusing me on how to do it i was wondering how would i do it.
i need to create 3 objects in another classes constuctor n store them in an arraylist
You'll have to provide more details.
Use the new statement to create an instance of an object
Use the add() method to add objects to an arraylist.
If you don't understand my answer, don't ignore it, ask a question.
yeah i get that but i have to do it in another classes constuctor in the test class. like below i have to create a vehicle object in the class below's constuctor n store it , but in the test class ?
import java.util.*; import java.awt.*; import java.io.*; /** The Reservation System class stores all the data about the vehicles in the rental company. Also to allow the use to see what vehicles are allowed to be * rented by the company. * */ public class ReservationSystem { private String name; private ArrayList<Vehicle> vehicleList; /** * Constructor for the Reservation System class which. */ public ReservationSystem( String name) { this.name = name; vehicleList = new ArrayList <Vehicle>(); } /** This method allows users to be able to add a vehicle object which will then be stored in the arraylist. */ public void storeVehicle(Vehicle newVehicle) { vehicleList.add(newVehicle); //Adds to arraylist. }
What is the problem with creating an object in any class and storing it in an arraylist?
Can you post the code you are having problems with?
If you don't understand my answer, don't ignore it, ask a question.
there is no problem i was just wondering how i would create a class that woould do it
If you don't understand my answer, don't ignore it, ask a question.