MathUtilities.java 6.9KB

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