Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tx-techno-num
impactometre
Commits
38d854c4
Commit
38d854c4
authored
Jan 25, 2020
by
Clement Brizard
Browse files
fix: merge issue
parent
35ec19ab
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
120 deletions
+0
-120
model/classes/Journey.js
model/classes/Journey.js
+0
-120
No files found.
model/classes/Journey.js
deleted
100644 → 0
View file @
35ec19ab
'
use strict
'
var
uniqid
=
require
(
'
uniqid
'
)
/**
* A journey has a mean of transportation,
* a distance and a number of people.
*/
export
default
class
Journey
{
/**
* The Journey class constructor.
* @param {TransportationMean} mean The mean of transportation.
* @param {Float} distance The distance of the journey.
* @param {Integer} numberOfPeople The number of people of the journey.
*/
constructor
(
mean
,
distance
,
numberOfPeople
)
{
this
.
_id
=
uniqid
()
this
.
_mean
=
mean
this
.
_distance
=
distance
this
.
_numberOfPeople
=
numberOfPeople
}
// Getters
/**
* Getter of the journey id.
*/
get
id
()
{
return
this
.
_id
}
/**
* Getter of the journey transportation mean.
*/
get
mean
()
{
return
this
.
_mean
}
/**
* Getter of the journey distance.
*/
get
distance
()
{
return
this
.
_distance
}
/**
* Getter of the journey number of people.
*/
get
numberOfPeople
()
{
return
this
.
_numberOfPeople
}
// Setters
/**
* Setter of the journey transportation mean.
* @param {TransportationMean} transportationMean - The new journey transportation mean.
*/
set
mean
(
transportationMean
)
{
this
.
_mean
=
transportationMean
}
/**
* Setter of the journey distance.
* @param {Float} distance - The new journey distance.
*/
set
distance
(
distance
)
{
this
.
_distance
=
distance
}
/**
* Setter of the journey number of people.
* @param {Integer} numberOfPeople - The new journey number of people.
*/
set
numberOfPeople
(
numberOfPeople
)
{
this
.
_numberOfPeople
=
numberOfPeople
}
// Other methods
/**
* Computes the damage caused by a journey.
* @returns {ComponentDamage} The damage caused by journey, for each damage sphere.
*/
computeEmbodiedDamage
()
{
// Get the transportation mean damage for one personKm or one kilometer
const
transportationMeanDamage
=
new
ComponentDamage
(
this
.
mean
.
embodied
)
// Initialize the returned damage
const
embodiedDamage
=
new
ComponentDamage
()
// Compute damage for each sphere (calculation mode is by personKm or by kilometer)
if
(
this
.
mean
.
isComputedByPersonKm
)
{
// Compute the personKilometers amount
const
personKmAmount
=
this
.
distance
*
this
.
numberOfPeople
embodiedDamage
.
mutate
(
category
=>
{
return
transportationMeanDamage
[
category
]
*
personKmAmount
})
}
else
{
embodiedDamage
.
mutate
(
category
=>
{
return
transportationMeanDamage
[
category
]
*
this
.
distance
})
}
// Return the journey embodied damage
return
embodiedDamage
}
/**
* Compute the total damage of the journey.
* There is a method with the same name for Software class and Hardware class.
* @returns {CompenentDamage} The total damage caused by the journey.
*/
computeDamage
()
{
return
this
.
computeEmbodiedDamage
()
}
}
module
.
exports
=
Journey
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment