Class Cargo

java.lang.Object
  extended by Cargo

public class Cargo
extends java.lang.Object

This class represents the cargo within our game.


Field Summary
private  int amount
          The number of units of this cargo
private  double cost
          The base price of the cargo
private  java.lang.String type
          The type of the cargo: 'gold', 'silver', 'Java textbooks', etc.
 
Constructor Summary
Cargo()
          The default constructor,it creates default cargo by initializing the type, amount, and the cost to random values
 
Method Summary
 int getAmount()
          Get the Amount value.
 double getCost()
          Get the Cost value.
 double getTotalPrice(double costFactor)
          Returns the total price of the cargo.
 java.lang.String getType()
          Get the Type value.
 void setAmount(int newAmount)
          Set the Amount value.
 void setCost(double newCost)
          Set the Cost value.
 void setType(java.lang.String newType)
          Set the Type value.
 java.lang.String toString()
          Returns the cargo represented as a String
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

type

private java.lang.String type
The type of the cargo: 'gold', 'silver', 'Java textbooks', etc.


amount

private int amount
The number of units of this cargo


cost

private double cost
The base price of the cargo

Constructor Detail

Cargo

public Cargo()
The default constructor,it creates default cargo by initializing the type, amount, and the cost to random values

Method Detail

getType

public java.lang.String getType()
Get the Type value.

Returns:
the Type value.

setType

public void setType(java.lang.String newType)
Set the Type value.

Parameters:
newType - The new Type value.

getAmount

public int getAmount()
Get the Amount value.

Returns:
the Amount value.

setAmount

public void setAmount(int newAmount)
Set the Amount value.

Parameters:
newAmount - The new Amount value.

getCost

public double getCost()
Get the Cost value.

Returns:
the Cost value.

setCost

public void setCost(double newCost)
Set the Cost value.

Parameters:
newCost - The new Cost value.

toString

public java.lang.String toString()
Returns the cargo represented as a String

Overrides:
toString in class java.lang.Object
Returns:
a String representation of the cargo

getTotalPrice

public double getTotalPrice(double costFactor)
Returns the total price of the cargo. This is the product of the passed cost factor, the quantity, and the base cost per unit.

Parameters:
costFactor - The cost factor to be used in the computation
Returns:
The total price of this Cargo