|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
Problem in add method please help
import java.util.*;
public class BoatHireCompany { private ArrayList <Boat> theBoats; // private RowBoat [] theRowBoats; // private PedalBoat [] thePedalBoats; // private Arraylist <PedalBoat> thePedalBoat = new Arraylist <PedalBoat> (); //should this be in? private int numRowBoats; private int maxRowBoats; private int numPedalBoats; private int maxPedalBoats; public BoatHireCompany (int numR, int numP) { theBoats = new ArrayList <Boat> (maxRowBoats); theBoats = new ArrayList <Boat> (maxPedalBoats); maxRowBoats = numR; maxPedalBoats = numP; numRowBoats = 0; numPedalBoats = 0; // theBoats = new ArrayList <Boat> (maxBoat); // theRowBoats = new RowBoat [maxRowBoats]; // thePedalBoats = new PedalBoat [maxPedalBoats]; } public boolean addRowBoat( Boat newBoats ) { if ( numRowBoats == maxRowBoats ) { return false; } else { theBoats.add(newBoat); THIS IS WHERE IT HAS A PROBLEM BUT I CANT SEEM TO FIGURE OUT HOW TO CORRECT IT numRowBoats++; return true; } } |
|
#2
|
|||
|
|||
|
Your code reads:
theBoats.add(newBoat); While the parameter name is newBoats (note the "s"). Maybe thats the problem? |
![]() |
| Viewing: Dev Articles Community Forums > Programming > Java Development > Problem in add method please help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|