mirror of
https://github.com/Myzel394/NumberHub.git
synced 2025-06-18 16:25:27 +02:00
Added torque (#29)
This commit is contained in:
parent
6b58f112c3
commit
06af4e1a2a
@ -1081,6 +1081,42 @@
|
||||
<string name="kilopond">Kilopond</string>
|
||||
<string name="kilopond_short">kp</string>
|
||||
|
||||
<!--Torque-->
|
||||
<string name="newton_meter">Newton meter</string>
|
||||
<string name="newton_meter_short">N*m</string>
|
||||
<string name="newton_centimeter">Newton centimeter</string>
|
||||
<string name="newton_centimeter_short">N*cm</string>
|
||||
<string name="newton_millimeter">Newton millimeter</string>
|
||||
<string name="newton_millimeter_short">N*mm</string>
|
||||
<string name="kilonewton_meter">Kilonewton meter</string>
|
||||
<string name="kilonewton_meter_short">kN*m</string>
|
||||
<string name="dyne_meter">Dyne meter</string>
|
||||
<string name="dyne_meter_short">dyn*m</string>
|
||||
<string name="dyne_centimeter">Dyne centimeter</string>
|
||||
<string name="dyne_centimeter_short">dyn*cm</string>
|
||||
<string name="dyne_millimeter">Dyne millimeter</string>
|
||||
<string name="dyne_millimeter_short">dyn*mm</string>
|
||||
<string name="kilogram_force_meter">Kilogram-force meter</string>
|
||||
<string name="kilogram_force_meter_short">kgf*m</string>
|
||||
<string name="kilogram_force_centimeter">Kilogram-force centimeter</string>
|
||||
<string name="kilogram_force_centimeter_short">kgf*cm</string>
|
||||
<string name="kilogram_force_millimeter">Kilogram-force millimeter</string>
|
||||
<string name="kilogram_force_millimeter_short">kgf*mm</string>
|
||||
<string name="gram_force_meter">Gram-force meter</string>
|
||||
<string name="gram_force_meter_short">gf*m</string>
|
||||
<string name="gram_force_centimeter">Gram-force centimeter</string>
|
||||
<string name="gram_force_centimeter_short">gf*cm</string>
|
||||
<string name="gram_force_millimeter">Gram-force millimeter</string>
|
||||
<string name="gram_force_millimeter_short">gf*mm</string>
|
||||
<string name="ounce_force_foot">Ounce-force foot</string>
|
||||
<string name="ounce_force_foot_short">ozf*ft</string>
|
||||
<string name="ounce_force_inch">Ounce-force inch</string>
|
||||
<string name="ounce_force_inch_short">ozf*in</string>
|
||||
<string name="pound_force_foot">Pound-force foot</string>
|
||||
<string name="pound_force_foot_short">lbf*ft</string>
|
||||
<string name="pound_force_inch">Pound-force inch</string>
|
||||
<string name="pound_force_inch_short">lbf*in</string>
|
||||
|
||||
<!--Groups-->
|
||||
<string name="length">Length</string>
|
||||
<string name="time">Time</string>
|
||||
@ -1102,6 +1138,7 @@
|
||||
<string name="electrostatic_capacitance">Capacitance</string>
|
||||
<string name="prefix">Prefix</string>
|
||||
<string name="force">Force</string>
|
||||
<string name="torque">Torque</string>
|
||||
|
||||
<!--Screen names-->
|
||||
<string name="units_screen_from">Convert from</string>
|
||||
|
@ -51,4 +51,5 @@ enum class UnitGroup(
|
||||
ELECTROSTATIC_CAPACITANCE(res = R.string.electrostatic_capacitance),
|
||||
PREFIX(res = R.string.prefix),
|
||||
FORCE(res = R.string.force),
|
||||
TORQUE(res = R.string.torque),
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ import com.sadellie.unitto.data.units.collections.pressureCollection
|
||||
import com.sadellie.unitto.data.units.collections.speedCollection
|
||||
import com.sadellie.unitto.data.units.collections.temperatureCollection
|
||||
import com.sadellie.unitto.data.units.collections.timeCollection
|
||||
import com.sadellie.unitto.data.units.collections.torqueCollection
|
||||
import com.sadellie.unitto.data.units.collections.volumeCollection
|
||||
import java.math.BigDecimal
|
||||
import javax.inject.Inject
|
||||
@ -85,6 +86,7 @@ class AllUnitsRepository @Inject constructor() {
|
||||
UnitGroup.ELECTROSTATIC_CAPACITANCE to electrostaticCapacitance,
|
||||
UnitGroup.PREFIX to prefixCollection,
|
||||
UnitGroup.FORCE to forceCollection,
|
||||
UnitGroup.TORQUE to torqueCollection
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -574,4 +574,23 @@ object MyUnitIDS {
|
||||
const val ounce_force = "ounce_force"
|
||||
const val pond = "pond"
|
||||
const val kilopond = "kilopond"
|
||||
|
||||
// TORQUE
|
||||
const val newton_meter = "newton_meter"
|
||||
const val newton_centimeter = "newton_centimeter"
|
||||
const val newton_millimeter = "newton_millimeter"
|
||||
const val kilonewton_meter = "kilonewton_meter"
|
||||
const val dyne_meter = "dyne_meter"
|
||||
const val dyne_centimeter = "dyne_centimeter"
|
||||
const val dyne_millimeter = "dyne_millimeter"
|
||||
const val kilogram_force_meter = "kilogram_force_meter"
|
||||
const val kilogram_force_centimeter = "kilogram_force_centimeter"
|
||||
const val kilogram_force_millimeter = "kilogram_force_millimeter"
|
||||
const val gram_force_meter = "gram_force_meter"
|
||||
const val gram_force_centimeter = "gram_force_centimeter"
|
||||
const val gram_force_millimeter = "gram_force_millimeter"
|
||||
const val ounce_force_foot = "ounce_force_foot"
|
||||
const val ounce_force_inch = "ounce_force_inch"
|
||||
const val pound_force_foot = "pound_force_foot"
|
||||
const val pound_force_inch = "pound_force_inch"
|
||||
}
|
||||
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Unitto is a unit converter for Android
|
||||
* Copyright (c) 2023 Elshan Agaev
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sadellie.unitto.data.units.collections
|
||||
|
||||
import com.sadellie.unitto.data.model.AbstractUnit
|
||||
import com.sadellie.unitto.data.model.MyUnit
|
||||
import com.sadellie.unitto.data.model.UnitGroup
|
||||
import com.sadellie.unitto.data.units.MyUnitIDS
|
||||
import com.sadellie.unitto.data.units.R
|
||||
import java.math.BigDecimal
|
||||
|
||||
val torqueCollection: List<AbstractUnit> by lazy {
|
||||
listOf(
|
||||
MyUnit(MyUnitIDS.dyne_millimeter, BigDecimal.valueOf(1), UnitGroup.TORQUE, R.string.dyne_millimeter, R.string.dyne_millimeter_short),
|
||||
MyUnit(MyUnitIDS.dyne_centimeter, BigDecimal.valueOf(10), UnitGroup.TORQUE, R.string.dyne_centimeter, R.string.dyne_centimeter_short),
|
||||
MyUnit(MyUnitIDS.dyne_meter, BigDecimal.valueOf(1000), UnitGroup.TORQUE, R.string.dyne_meter, R.string.dyne_meter_short),
|
||||
MyUnit(MyUnitIDS.newton_millimeter, BigDecimal.valueOf(100000), UnitGroup.TORQUE, R.string.newton_millimeter, R.string.newton_millimeter_short),
|
||||
MyUnit(MyUnitIDS.newton_centimeter, BigDecimal.valueOf(1000000), UnitGroup.TORQUE, R.string.newton_centimeter, R.string.newton_centimeter_short),
|
||||
MyUnit(MyUnitIDS.newton_meter, BigDecimal.valueOf(100000000), UnitGroup.TORQUE, R.string.newton_meter, R.string.newton_meter_short),
|
||||
MyUnit(MyUnitIDS.kilonewton_meter, BigDecimal.valueOf(100000000000), UnitGroup.TORQUE, R.string.kilonewton_meter, R.string.kilonewton_meter_short),
|
||||
MyUnit(MyUnitIDS.gram_force_millimeter, BigDecimal.valueOf(980.665), UnitGroup.TORQUE, R.string.gram_force_millimeter, R.string.gram_force_millimeter_short),
|
||||
MyUnit(MyUnitIDS.gram_force_centimeter, BigDecimal.valueOf(9806.65), UnitGroup.TORQUE, R.string.gram_force_centimeter, R.string.gram_force_centimeter_short),
|
||||
MyUnit(MyUnitIDS.kilogram_force_millimeter, BigDecimal.valueOf(980665), UnitGroup.TORQUE, R.string.kilogram_force_millimeter, R.string.kilogram_force_millimeter_short),
|
||||
MyUnit(MyUnitIDS.gram_force_meter, BigDecimal.valueOf(980665), UnitGroup.TORQUE, R.string.gram_force_meter, R.string.gram_force_meter_short),
|
||||
MyUnit(MyUnitIDS.kilogram_force_centimeter, BigDecimal.valueOf(9806650), UnitGroup.TORQUE, R.string.kilogram_force_centimeter, R.string.kilogram_force_centimeter_short),
|
||||
MyUnit(MyUnitIDS.kilogram_force_meter, BigDecimal.valueOf(980665000), UnitGroup.TORQUE, R.string.kilogram_force_meter, R.string.kilogram_force_meter_short),
|
||||
MyUnit(MyUnitIDS.ounce_force_foot, BigDecimal.valueOf(8473862.4), UnitGroup.TORQUE, R.string.ounce_force_foot, R.string.ounce_force_foot_short),
|
||||
MyUnit(MyUnitIDS.ounce_force_inch, BigDecimal.valueOf(706155.2), UnitGroup.TORQUE, R.string.ounce_force_inch, R.string.ounce_force_inch_short),
|
||||
MyUnit(MyUnitIDS.pound_force_foot, BigDecimal.valueOf(135581800), UnitGroup.TORQUE, R.string.pound_force_foot, R.string.pound_force_foot_short),
|
||||
MyUnit(MyUnitIDS.pound_force_inch, BigDecimal.valueOf(1.1298483333333334E7), UnitGroup.TORQUE, R.string.pound_force_inch, R.string.pound_force_inch_short),
|
||||
)
|
||||
}
|
@ -439,6 +439,27 @@ class AllUnitsTest {
|
||||
kilopond.checkWith(kilonewton, "6553", "64.26298")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testTorque() = testWithUnits {
|
||||
newton_meter.checkWith(dyne_meter, "2134", "213400000")
|
||||
newton_centimeter.checkWith(kilogram_force_millimeter, "2345", "2391.23452")
|
||||
newton_millimeter.checkWith(pound_force_inch, "2345", "20.755")
|
||||
kilonewton_meter.checkWith(kilogram_force_meter, "2134", "217607.43985")
|
||||
dyne_meter.checkWith(newton_centimeter, "2134", "2.134")
|
||||
dyne_centimeter.checkWith(gram_force_centimeter, "2134", "2.17607")
|
||||
dyne_millimeter.checkWith(gram_force_millimeter, "2134", "2.17607")
|
||||
kilogram_force_meter.checkWith(dyne_millimeter, "2134", "2092739110000")
|
||||
kilogram_force_centimeter.checkWith(gram_force_meter, "2134", "21340")
|
||||
kilogram_force_millimeter.checkWith(ounce_force_inch, "2134", "2963.56822")
|
||||
gram_force_meter.checkWith(newton_millimeter, "2134", "20927.3911")
|
||||
gram_force_centimeter.checkWith(kilogram_force_centimeter, "2134", "2.134")
|
||||
gram_force_millimeter.checkWith(kilonewton_meter, "2134", "0.00002")
|
||||
ounce_force_foot.checkWith(kilogram_force_millimeter, "2134", "18439.75503")
|
||||
ounce_force_inch.checkWith(dyne_meter, "2134", "1506935.1968")
|
||||
pound_force_foot.checkWith(newton_millimeter, "2134", "2893315.612")
|
||||
pound_force_inch.checkWith(ounce_force_foot, "2134", "2845.33337")
|
||||
}
|
||||
|
||||
private fun String.checkWith(checkingId: String, value: String, expected: String) {
|
||||
val unitFrom = allUnitsRepository.getById(this)
|
||||
val unitTo = allUnitsRepository.getById(checkingId)
|
||||
|
Loading…
x
Reference in New Issue
Block a user