mirror of
https://github.com/Myzel394/NumberHub.git
synced 2025-06-18 16:25:27 +02:00
Added force (#29)
This commit is contained in:
parent
4a646a0a7e
commit
273cbcc0ff
@ -1049,6 +1049,38 @@
|
||||
<string name="prefix_quecto">Quecto</string>
|
||||
<string name="prefix_quecto_short">q</string>
|
||||
|
||||
<!--Force-->
|
||||
<string name="newton">Newton</string>
|
||||
<string name="newton_short">N</string>
|
||||
<string name="kilonewton">Kilonewton</string>
|
||||
<string name="kilonewton_short">kN</string>
|
||||
<string name="gram_force">Gram-force</string>
|
||||
<string name="gram_force_short">gf</string>
|
||||
<string name="kilogram_force">Kilogram-force</string>
|
||||
<string name="kilogram_force_short">kgf</string>
|
||||
<string name="ton_force">Ton-force</string>
|
||||
<string name="ton_force_short">tf</string>
|
||||
<string name="millinewton">Millinewton</string>
|
||||
<string name="millinewton_short">mN</string>
|
||||
<string name="attonewton">attonewton</string>
|
||||
<string name="attonewton_short">aN</string>
|
||||
<string name="dyne">dyne</string>
|
||||
<string name="dyne_short">dyn</string>
|
||||
<string name="joule_per_meter">Joule/meter</string>
|
||||
<string name="joule_per_meter_short">J/m</string>
|
||||
<string name="joule_per_centimeter">Joule/centimeter</string>
|
||||
<string name="joule_per_centimeter_short">J/cm</string>
|
||||
<string name="kilopound_force">Kilopound-force</string>
|
||||
<string name="kilopound_force_short">kipf</string>
|
||||
<string name="pound_force">Pound-force</string>
|
||||
<string name="pound_force_short">lbf</string>
|
||||
<string name="ounce_force">Ounce-force</string>
|
||||
<string name="ounce_force_short">ozf</string>
|
||||
<string name="pond">Pond</string>
|
||||
<string name="pond_short">p</string>
|
||||
<string name="kilopond">Kilopond</string>
|
||||
<string name="kilopond_short">kp</string>
|
||||
|
||||
<!--Groups-->
|
||||
<string name="length">Length</string>
|
||||
<string name="time">Time</string>
|
||||
@ -1069,6 +1101,7 @@
|
||||
<string name="number_base">Base</string>
|
||||
<string name="electrostatic_capacitance">Capacitance</string>
|
||||
<string name="prefix">Prefix</string>
|
||||
<string name="force">Force</string>
|
||||
|
||||
<!--Screen names-->
|
||||
<string name="units_screen_from">Convert from</string>
|
||||
|
@ -50,4 +50,5 @@ enum class UnitGroup(
|
||||
NUMBER_BASE(res = R.string.number_base),
|
||||
ELECTROSTATIC_CAPACITANCE(res = R.string.electrostatic_capacitance),
|
||||
PREFIX(res = R.string.prefix),
|
||||
FORCE(res = R.string.force),
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ import com.sadellie.unitto.data.units.collections.timeCollection
|
||||
import com.sadellie.unitto.data.units.collections.volumeCollection
|
||||
import com.sadellie.unitto.data.database.UnitsEntity
|
||||
import com.sadellie.unitto.data.units.collections.electrostaticCapacitance
|
||||
import com.sadellie.unitto.data.units.collections.forceCollection
|
||||
import com.sadellie.unitto.data.units.collections.prefix
|
||||
import java.math.BigDecimal
|
||||
import javax.inject.Inject
|
||||
@ -83,6 +84,7 @@ class AllUnitsRepository @Inject constructor() {
|
||||
UnitGroup.NUMBER_BASE to numberBaseCollection,
|
||||
UnitGroup.ELECTROSTATIC_CAPACITANCE to electrostaticCapacitance,
|
||||
UnitGroup.PREFIX to prefix,
|
||||
UnitGroup.FORCE to forceCollection,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -557,4 +557,21 @@ object MyUnitIDS {
|
||||
const val prefix_yocto = "yocto"
|
||||
const val prefix_ronto = "ronto"
|
||||
const val prefix_quecto = "quecto"
|
||||
|
||||
// FORCE
|
||||
const val newton = "newton"
|
||||
const val kilonewton = "kilonewton"
|
||||
const val gram_force = "gram_force"
|
||||
const val kilogram_force = "kilogram_force"
|
||||
const val ton_force = "ton_force"
|
||||
const val millinewton = "millinewton"
|
||||
const val attonewton = "attonewton"
|
||||
const val dyne = "dyne"
|
||||
const val joule_per_meter = "joule_per_meter"
|
||||
const val joule_per_centimeter = "joule_per_centimeter"
|
||||
const val kilopound_force = "kilopound_force"
|
||||
const val pound_force = "pound_force"
|
||||
const val ounce_force = "ounce_force"
|
||||
const val pond = "pond"
|
||||
const val kilopond = "kilopond"
|
||||
}
|
||||
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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 forceCollection: List<AbstractUnit> by lazy {
|
||||
listOf(
|
||||
MyUnit(MyUnitIDS.newton, BigDecimal.valueOf(1E+18), UnitGroup.FORCE, R.string.newton, R.string.newton_short),
|
||||
MyUnit(MyUnitIDS.kilonewton, BigDecimal.valueOf(1E+21), UnitGroup.FORCE, R.string.kilonewton, R.string.kilonewton_short),
|
||||
MyUnit(MyUnitIDS.gram_force, BigDecimal.valueOf(9.80665E+15), UnitGroup.FORCE, R.string.gram_force, R.string.gram_force_short),
|
||||
MyUnit(MyUnitIDS.kilogram_force, BigDecimal.valueOf(9.80665E+18), UnitGroup.FORCE, R.string.kilogram_force, R.string.kilogram_force_short),
|
||||
MyUnit(MyUnitIDS.ton_force, BigDecimal.valueOf(9.80665E+21), UnitGroup.FORCE, R.string.ton_force, R.string.ton_force_short),
|
||||
MyUnit(MyUnitIDS.millinewton, BigDecimal.valueOf(1E+15), UnitGroup.FORCE, R.string.millinewton, R.string.millinewton_short),
|
||||
MyUnit(MyUnitIDS.attonewton, BigDecimal.valueOf(1), UnitGroup.FORCE, R.string.attonewton, R.string.attonewton_short),
|
||||
MyUnit(MyUnitIDS.dyne, BigDecimal.valueOf(1E+13), UnitGroup.FORCE, R.string.dyne, R.string.dyne_short),
|
||||
MyUnit(MyUnitIDS.joule_per_meter, BigDecimal.valueOf(1E+18), UnitGroup.FORCE, R.string.joule_per_meter, R.string.joule_per_meter_short),
|
||||
MyUnit(MyUnitIDS.joule_per_centimeter, BigDecimal.valueOf(1E+16), UnitGroup.FORCE, R.string.joule_per_centimeter, R.string.joule_per_centimeter_short),
|
||||
MyUnit(MyUnitIDS.kilopound_force, BigDecimal.valueOf(4.448221615255E+21), UnitGroup.FORCE, R.string.kilopound_force, R.string.kilopound_force_short),
|
||||
MyUnit(MyUnitIDS.pound_force, BigDecimal.valueOf(4.4482216152550001E18), UnitGroup.FORCE, R.string.pound_force, R.string.pound_force_short),
|
||||
MyUnit(MyUnitIDS.ounce_force, BigDecimal.valueOf(2.78013850953423008E17), UnitGroup.FORCE, R.string.ounce_force, R.string.ounce_force_short),
|
||||
MyUnit(MyUnitIDS.pond, BigDecimal.valueOf(9.80665E+15), UnitGroup.FORCE, R.string.pond, R.string.pond_short),
|
||||
MyUnit(MyUnitIDS.kilopond, BigDecimal.valueOf(9.80665E+18), UnitGroup.FORCE, R.string.kilopond, R.string.kilopond_short),
|
||||
)
|
||||
}
|
@ -420,6 +420,25 @@ class AllUnitsTest {
|
||||
prefix_quecto.checkWith(prefix_base, "1", "0.000000000000000000000000000001")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testForce() = testWithUnits {
|
||||
newton.checkWith(pond, "6553", "668220.03436")
|
||||
kilonewton.checkWith(kilopound_force, "6553", "1473.173")
|
||||
gram_force.checkWith(kilonewton, "6553", "0.06426")
|
||||
kilogram_force.checkWith(ton_force, "6553", "6.553")
|
||||
ton_force.checkWith(millinewton, "6553", "64262977450")
|
||||
millinewton.checkWith(kilonewton, "6553", "0.00655")
|
||||
attonewton.checkWith(dyne, "6553123123", "0.00066")
|
||||
dyne.checkWith(joule_per_meter, "6553", "0.06553")
|
||||
joule_per_meter.checkWith(pond, "6553", "668220.03436")
|
||||
joule_per_centimeter.checkWith(kilopond, "6553", "6.6822")
|
||||
kilopound_force.checkWith(kilopond, "6553", "2972390.80061")
|
||||
pound_force.checkWith(ounce_force, "6553", "104848")
|
||||
ounce_force.checkWith(pound_force, "6553", "409.5625")
|
||||
pond.checkWith(kilonewton, "6553", "0.06426")
|
||||
kilopond.checkWith(kilonewton, "6553", "64.26298")
|
||||
}
|
||||
|
||||
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