MathUtilities.java 7.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. /**
  2. * Created by dan on 6/14/17.
  3. */
  4. public class MathUtilities {
  5. /**
  6. * @param baseValue starting value
  7. * @param difference value to add to starting value
  8. * @return sum of `baseValue` and `difference`
  9. */
  10. public Integer add(int baseValue, int difference) {
  11. int container = baseValue + difference;
  12. return container;
  13. }
  14. /**
  15. * @param baseValue starting value
  16. * @param difference value to add to starting value
  17. * @return sum of `baseValue` and `difference`
  18. */
  19. public Long add(long baseValue, long difference) {
  20. long container = baseValue + difference;
  21. return container;
  22. }
  23. /**
  24. * @param baseValue starting value
  25. * @param difference value to add to starting value
  26. * @return sum of `baseValue` and `difference`
  27. */
  28. public Short add(short baseValue, short difference) {
  29. int container = baseValue;
  30. int container2 = difference;
  31. int total = (container) + (container2);
  32. return (short)total;
  33. }
  34. public int cont (){
  35. return 0;
  36. }
  37. /**
  38. * @param baseValue starting value
  39. * @param difference value to add to starting value
  40. * @return sum of `baseValue` and `difference`
  41. */
  42. public Byte add(byte baseValue, byte difference) {
  43. int container = baseValue + difference;
  44. return (byte)(container) ;
  45. }
  46. /**
  47. * @param baseValue starting value
  48. * @param difference value to add to starting value
  49. * @return sum of `baseValue` and `difference`
  50. */
  51. public Float add(float baseValue, float difference) {
  52. float container = baseValue + difference;
  53. return container;
  54. }
  55. /**
  56. * @param baseValue starting value
  57. * @param difference value to add to starting value
  58. * @return sum of `baseValue` and `difference`
  59. */
  60. public Double add(double baseValue, double difference) {
  61. double container = baseValue + difference;
  62. return container;
  63. }
  64. /**
  65. * @param baseValue starting value
  66. * @param difference value to subtract from starting value
  67. * @return difference between `baseValue` and `difference`
  68. */
  69. public Integer subtract(int baseValue, int difference) {
  70. int container = baseValue - difference;
  71. return container;
  72. }
  73. /**
  74. * @param baseValue starting value
  75. * @param difference value to subtract from starting value
  76. * @return difference between `baseValue` and `difference`
  77. */
  78. public Long subtract(long baseValue, long difference) {
  79. long container = baseValue - difference;
  80. return container;
  81. }
  82. /**
  83. * @param baseValue starting value
  84. * @param difference value to subtract from starting value
  85. * @return difference between `baseValue` and `difference`
  86. */
  87. public Short subtract(short baseValue, short difference) {
  88. int container = baseValue - difference;
  89. return (short) container;
  90. }
  91. /**
  92. * @param baseValue starting value
  93. * @param difference value to subtract from starting value
  94. * @return difference between `baseValue` and `difference`
  95. */
  96. public Byte subtract(byte baseValue, byte difference) {
  97. int container = baseValue - difference;
  98. return (byte)container;
  99. }
  100. /**
  101. * @param baseValue starting value
  102. * @param difference value to subtract from starting value
  103. * @return difference between `baseValue` and `difference`
  104. */
  105. public Float subtract(float baseValue, float difference) {
  106. float container = baseValue - difference;
  107. return container;
  108. }
  109. /**
  110. * @param baseValue starting value
  111. * @param difference value to subtract from starting value
  112. * @return difference between `baseValue` and `difference`
  113. */
  114. public Double subtract(double baseValue, double difference) {
  115. double container = baseValue - difference;
  116. return container;
  117. }
  118. /**
  119. * @param dividend value to be divided
  120. * @param divisor value to divide by
  121. * @return division of `dividend` by `divisor
  122. */
  123. public Integer divide(int dividend, int divisor) {
  124. int container = dividend / divisor;
  125. return container;
  126. }
  127. /**
  128. * @param dividend value to be divided
  129. * @param divisor value to divide by
  130. * @return division of `dividend` by `divisor
  131. */
  132. public Long divide(long dividend, long divisor) {
  133. long container = dividend / divisor;
  134. return container;
  135. }
  136. /**
  137. * @param dividend value to be divided
  138. * @param divisor value to divide by
  139. * @return division of `dividend` by `divisor
  140. */
  141. public Short divide(short dividend, short divisor) {
  142. int container = dividend / divisor;
  143. return (short) container;
  144. }
  145. /**
  146. * @param dividend value to be divided
  147. * @param divisor value to divide by
  148. * @return division of `dividend` by `divisor
  149. */
  150. public Byte divide(byte dividend, byte divisor) {
  151. int container = dividend / divisor;
  152. return (byte) container;
  153. }
  154. /**
  155. * @param dividend value to be divided
  156. * @param divisor value to divide by
  157. * @return division of `dividend` by `divisor
  158. */
  159. public Float divide(float dividend, float divisor) {
  160. float container = dividend / divisor;
  161. return container;
  162. }
  163. /**
  164. * @param dividend value to be divided
  165. * @param divisor value to divide by
  166. * @return division of `dividend` by `divisor
  167. */
  168. public Double divide(double dividend, double divisor) {
  169. double container = dividend / divisor;
  170. return container;
  171. }
  172. /**
  173. * @param multiplicand value to be multiplied
  174. * @param multiplier value to multiply by
  175. * @return product of `multiplicand` by `multiplier`
  176. */
  177. public Integer multiply(int multiplicand, int multiplier) {
  178. int container = multiplicand * multiplier;
  179. return container;
  180. }
  181. /**
  182. * @param multiplicand value to be multiplied
  183. * @param multiplier value to multiply by
  184. * @return product of `multiplicand` by `multiplier`
  185. */
  186. public Long multiply(long multiplicand, long multiplier) {
  187. long container = multiplicand * multiplier;
  188. return container;
  189. }
  190. /**
  191. * @param multiplicand value to be multiplied
  192. * @param multiplier value to multiply by
  193. * @return product of `multiplicand` by `multiplier`
  194. */
  195. public Short multiply(short multiplicand, short multiplier) {
  196. int container = multiplicand * multiplier;
  197. return (short)container;
  198. }
  199. /**
  200. * @param multiplicand value to be multiplied
  201. * @param multiplier value to multiply by
  202. * @return product of `multiplicand` by `multiplier`
  203. */
  204. public Byte multiply(byte multiplicand, byte multiplier) {
  205. int container = multiplicand * multiplier;
  206. return (byte)container;
  207. }
  208. /**
  209. * @param multiplicand value to be multiplied
  210. * @param multiplier value to multiply by
  211. * @return product of `multiplicand` by `multiplier`
  212. */
  213. public Float multiply(float multiplicand, float multiplier) {
  214. float container = multiplicand * multiplier;
  215. return container;
  216. }
  217. /**
  218. * @param multiplicand value to be multiplied
  219. * @param multiplier value to multiply by
  220. * @return product of `multiplicand` by `multiplier`
  221. */
  222. public Double multiply(double multiplicand, double multiplier) {
  223. double container = multiplicand * multiplier;
  224. return container;
  225. }
  226. /**
  227. * @return true
  228. */
  229. public Boolean returnTrue() {
  230. return true;
  231. }
  232. /**
  233. * @return false
  234. */
  235. public Boolean returnFalse() {
  236. return false;
  237. }
  238. }