|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--Carriage
This abstract class defines a carriage.
Field Summary | |
private int |
carriageNumber
Carriage number |
private boolean[][] |
carriagePlan
Plan for carriage. |
private int |
noOfColumns
Number of columns in a carriage |
private int |
noOfRows
Number of rows in a carriage |
private int[] |
noOfVacantPlaces
Array to keep track numbers of vacant places of each type of place. |
Constructor Summary | |
Carriage(int carriageNo,
int rows,
int columns)
1a) Constructs a new Carriage class that initializes the carriageNumber, noOfRows, noOfColumns, carriagePlan, and noOfVacantPlaces. |
Method Summary | |
void |
drawCarriagePlan(int placeNo)
1j) Draw the plan of the carriage. |
private int |
findRowNoOfFirstVacantPlace(int typePlace)
1g) Find row-number of the first vacant place of the specified type in the carriage. |
int |
getCarriageNo()
1b) Returns carriage number of the carriage. |
abstract java.lang.String |
getNameOfTypePlace(int typePlace)
Abstract method that returns the name of the type of place |
boolean |
hasVacantPlace(int typePlace)
1d) Checks if the carriage has vacant places of the type specified in the parameter. |
boolean |
isFull()
1e) Check if the carriage is full. |
private int |
placePositionToPlaceNo(int i,
int j)
1h) Convert (i,j)-pair in the plan to place number in the carriage. |
int |
reserveFirstVacantPlace(int typePlace)
1i) Reserve the first vacant place of the specified type. |
private void |
setOccupied(int i,
int j)
1c) Sets the given place in the carriage plan to occupied. |
int |
typePlaceWithLeastOccupancy()
1f) Find the type of place in the carriage which has least occupancy and returns -1 if the carriage is full. |
Methods inherited from class java.lang.Object |
|
Field Detail |
private int carriageNumber
private int noOfRows
private int noOfColumns
private boolean[][] carriagePlan
private int[] noOfVacantPlaces
Constructor Detail |
public Carriage(int carriageNo, int rows, int columns)
Method Detail |
public int getCarriageNo()
private void setOccupied(int i, int j)
(i,j)
- Place location.public boolean hasVacantPlace(int typePlace)
public boolean isFull()
public int typePlaceWithLeastOccupancy()
private int findRowNoOfFirstVacantPlace(int typePlace)
typePlace
- Type of Place.private int placePositionToPlaceNo(int i, int j)
(i,j)
- Place location pair.public int reserveFirstVacantPlace(int typePlace)
public void drawCarriagePlan(int placeNo)
public abstract java.lang.String getNameOfTypePlace(int typePlace)
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |