allocate method
simulation: Produce nice-looking allocation-list of resources.
Implementation
List<String> allocate(int _r, int _c) {
/// devl:MIS use _c variable to control width
/// init(); must be done somewhere.
List<String> _l = [];
StringBuffer _sB = StringBuffer();
_l.add(
'Days Area: Car: Law: Machine:Money: Office: People: Time:');
for (var x = 0; x < _r; x++) {
String _dS = x.toString();
// devl:MIS padRight(5, ' ')
String _sbW = 'D:$_dS ';
_sB.write(_sbW.padRight(5, ' '));
/// Write one of 8 resources in right place
/// int nextInt(int max);
int _rand = random.nextInt(8); // get one of first 8 resources.
for (var x = 0; x < 8; x++) {
if (x == _rand) {
// padRight(8, ' ')
String _sP = resL[x].padRight(8, ' ');
_sB.write(_sP);
} else {
_sB.write('_______ ');
}
}
_l.add(_sB.toString());
// _sB.write();
_sB.clear();
}
return _l;
}