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
Printable View
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.
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 ?
Code java: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?
there is no problem i was just wondering how i would create a class that woould do it