From ba49723666cadf6f2a0ca72cd18cbaf9336f4a1a Mon Sep 17 00:00:00 2001 From: serso Date: Thu, 27 Oct 2011 00:29:15 +0400 Subject: [PATCH] new constants added --- res/values-ru/strings.xml | 4 ++++ res/values/strings.xml | 4 ++++ .../solovyev/android/calculator/math/MathType.java | 8 +++++++- .../android/calculator/model/VarsRegisterImpl.java | 12 ++++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index 52702a9e..466f8170 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -60,6 +60,10 @@ Отношение длины окружности к диаметру Вещесвтенное число, такое что производная функции f(x) = e^x в точке x = 0 равно 1 Мнимая единица, определённая как i^2 = −1 + Скорость света в вакууме, м·с^-1 + Гравитационная постоянная, с^3·кг^−1·с^−2 + Постоянная Планка - коэффициент, связывающий величину энергии электромагнитного излучения с его частотой, Дж·с + Привидённая постоянная Планка, Дж·с Не число Бесконечность Введите новое выражение diff --git a/res/values/strings.xml b/res/values/strings.xml index ff9dc258..e1a4fd65 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -63,6 +63,10 @@ Ratio of any circle\'s circumference to its diameter Unique real number such that the value of the derivative (slope of the tangent line) of the function f(x) = e^x at the point x = 0 is equal to 1 Imaginary unit, defined such that i^2 = −1 + Speed of light in vacuum, m·s^-1 + The gravitational constant is an empirical physical constant involved in the calculation of the gravitational attraction between objects with mass, m^3·kg^−1·s^−2 + Physical constant reflecting the sizes of energy quanta in quantum mechanics, J·s + Reduced Planck constant, J·s Not a number Infinity diff --git a/src/main/java/org/solovyev/android/calculator/math/MathType.java b/src/main/java/org/solovyev/android/calculator/math/MathType.java index 159192a4..23d1a8e2 100644 --- a/src/main/java/org/solovyev/android/calculator/math/MathType.java +++ b/src/main/java/org/solovyev/android/calculator/math/MathType.java @@ -321,12 +321,18 @@ public enum MathType { public static final String PI = "π"; public static final String E = "e"; + public static final String C = "c"; + public static final Double C_VALUE = 299792458d; + public static final String G = "G"; + public static final Double G_VALUE = 6.6738480E-11; + public static final String H_REDUCED = "h"; + public static final Double H_REDUCED_VALUE = 6.6260695729E-34 / ( 2 * Math.PI ); public final static String NAN = "NaN"; public final static String INFINITY = "∞"; public final static String INFINITY_JSCL = "Infinity"; - public static final List constants = Arrays.asList(E, PI, IMAGINARY_NUMBER, NAN, INFINITY); + public static final List constants = Arrays.asList(E, PI, C, G, H_REDUCED, IMAGINARY_NUMBER, NAN, INFINITY); /** * Method determines mathematical entity type for text substring starting from ith index diff --git a/src/main/java/org/solovyev/android/calculator/model/VarsRegisterImpl.java b/src/main/java/org/solovyev/android/calculator/model/VarsRegisterImpl.java index 724ba5a5..e6e82166 100644 --- a/src/main/java/org/solovyev/android/calculator/model/VarsRegisterImpl.java +++ b/src/main/java/org/solovyev/android/calculator/model/VarsRegisterImpl.java @@ -148,6 +148,18 @@ class VarsRegisterImpl implements VarsRegister { } else if (systemVarName.equals(MathType.PI)) { builder = new Var.Builder(systemVarName, Math.PI); varDescription = R.string.c_pi_description; + } else if (systemVarName.equals(MathType.C)) { + builder = new Var.Builder(systemVarName, MathType.C_VALUE); + varDescription = R.string.c_c_description; + } else if (systemVarName.equals(MathType.G)) { + builder = new Var.Builder(systemVarName, MathType.G_VALUE); + varDescription = R.string.c_g_description; +/* } else if (systemVarName.equals(MathType.H)) { + builder = new Var.Builder(systemVarName, MathType.H_VALUE); + varDescription = R.string.c_h_description;*/ + } else if (systemVarName.equals(MathType.H_REDUCED)) { + builder = new Var.Builder(systemVarName, MathType.H_REDUCED_VALUE); + varDescription = R.string.c_h_reduced_description; } else if (systemVarName.equals(MathType.IMAGINARY_NUMBER)) { builder = new Var.Builder(systemVarName, MathType.IMAGINARY_NUMBER_JSCL); varDescription = R.string.c_i_description;