Basic computation from some of my projects. For now nothing special, this is my first package I made, and if someone thinks it useful, let it use. I keep working on this from time to time.
p.s. This is a result of learning how to make my own packages.
Features
Basic and diverse computations which I use in my projects, nothing speacial.
- Gain calculation
- Sell price calculation
- Percent calculations (from percent , to percent)
- Basic travel calculation
Getting started
You have to have the latest version of Dart installed.
Usage
Simple examples of using calculations for seling price or gain from some price when we make or form seeling price with our gain.
DartList<double> pricesList = [1890.0, 560.0, 780.0, 256.0, 1450.0];
pricesList.forEach((item) {
//When we choice to calculate gain of some price value, other argument
// parameters have to be set to null or you will get exeption.
//First, you can calculate two types of price , this is the
//first, belov, with gain calculation.
final gain = PriceCalculation(startValue: item, gain: 20);
print("--| Result with gain:\n" + gain.toString() + "\n");
//Second type where we calculate seling price or end price (for seling).
final sellPirce = PriceCalculation(
startValue: item,
discount: 5,
tax: 20,
gain: null,
);
print("--| Seling price example:\n" + sellPirce.toString() + "\n");
});
//Simple example of using percent values. Two types of calculation:
//1. When we need percent of some value
dart var valFromPercent = PercentCalulations(
mainValue: 1450,
amount: null,
percent: 24,
);
print(valFromPercent.toString() + "\n");```
//2. When wen need how much procent for some amount
var whatPercent = PercentCalulations(
mainValue: 2450.00,
amount: 130.00,
percent: null,
);
print(whatPercent.toString() + "\n");
//Example 1 - Simple example of using calculations
var time = TimeTravel(destination: 11860, speed: 450);
print("1. Simple usage of calc of travel time");
print(
"Result for destination of 11.860 km with speed of 450 km/h a time arriving is:" +
time.toString() +
"\n",
);
//Example 2 - Using Time Travel calculation
//Simulation of driving with changing speed of moving, during driving a car,
//and calculation of the rest time of traveling.
List<double> speeds = [85, 90, 105, 120, 80, 60]; //km/h
List<double> distances = [15, 23, 10, 13, 17, 7]; //km
for (var i = 0; i < speeds.length; i++) {
final timeTra = TimeTravel(
destination: distances[i],
speed: speeds[i].roundToDouble(),
);
timeTra.calculate();
int h = int.parse(timeTra.hour!);
double m = (double.parse(timeTra.min!));
final durationMs = ((h + m) \* 1000)
.round(); //it is simulation some time of duration , it isn't relevant
print("You are driving now with speed of ${speeds[i]} km/h");
await Future.delayed(Duration(milliseconds: durationMs));
if (h != 0) {
print(
">you reach ${distances[i]} km distance for ${timeTra.hour}h and ${timeTra.min} min\n",
);
} else {
print(">you reach ${distances[i]} km distance for ${timeTra.min} min\n");
}
}
Additional information
No additional special information for now. It is to simple to write more info (for now).
- author: Flubo
- http: https://sites.google.com/view/borisbokan-en/home
- emailto: borisbokan@gmail.com