Difference between revisions of "2020 - Outlet"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
(GetDetails)
(Constructor)
Line 12: Line 12:
  
 
===Constructor===
 
===Constructor===
 +
The constructor accepts parameters for 'xCoord', 'yCoord', and 'maxCapacityBase'.
 +
 +
It uses 'this' to access the values for 'xCoord' and 'yCoord' of the object and sets the values to those passed. In this case 'this' is used to determine if we mean the parameter called 'xCoord' or the variable called 'xCoord'.
 +
 +
'capacity' is set by multipling 'maxCapacityBase' by '0.6', is 60% of 'maxCapacityBase'.
 +
 +
'maxCapacity' takes the 'maxCapacityBase' and is set by adding a random number between 0 and 50, and then subtracting a random number between 0 and 50.
 +
 +
'dailyCosts' are set using the following calculation:
 +
dailyCosts = maxCapacityBase * 0.2 + capacity * 0.5 + 100
 +
 +
Finally the 'NewDay' method is run.
  
 
===GetCapacity===
 
===GetCapacity===

Revision as of 12:53, 27 January 2020

Variables

Random

private static Random rnd

int

protected int visitsToday, xCoord, yCoord, capacity, maxCapacity;

double

protected double dailyCosts;

Methods

Constructor

The constructor accepts parameters for 'xCoord', 'yCoord', and 'maxCapacityBase'.

It uses 'this' to access the values for 'xCoord' and 'yCoord' of the object and sets the values to those passed. In this case 'this' is used to determine if we mean the parameter called 'xCoord' or the variable called 'xCoord'.

'capacity' is set by multipling 'maxCapacityBase' by '0.6', is 60% of 'maxCapacityBase'.

'maxCapacity' takes the 'maxCapacityBase' and is set by adding a random number between 0 and 50, and then subtracting a random number between 0 and 50.

'dailyCosts' are set using the following calculation:

dailyCosts = maxCapacityBase * 0.2 + capacity * 0.5 + 100

Finally the 'NewDay' method is run.

GetCapacity

This will just return the capacity stored in 'capacity'.

GetX

This will just return the value of 'xCoord'.

GetY

This will just return the value of 'yCoord'.

AlterDailyCost

This accepts a parameter called 'amount' (a double), this method will just add the value of 'amount' to the 'dailyCosts' variable.

AlterCapacity

IncrementVisits

This method will just increment the 'visitsToday' variable using 'visitsToday++'.

NewDay

This will just reset the 'visitsToday' back to 0.

CalculateDailyProfitLoss

This method will accept parameters for 'avgPricePerMeal' and 'avgCostPerMeal'. It will then return the result of this calcualtion:

(avgPricePerMeal - avgCostPerMeal) * visitsToday - dailyCosts

GetDetails

This declares a new string called 'details' which is then used to concatenate several bit of information together.

This string is then returned.