You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

CalcerFloatCalc.cs 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace coa4u
  5. {
  6. public class CalcerFloatCalc : CalcerFloat
  7. {
  8. public enum Operation
  9. {
  10. Add,
  11. Sub,
  12. Mul,
  13. Div
  14. }
  15. private Operation operation;
  16. private CalcerFloat first;
  17. private CalcerFloat second;
  18. public CalcerFloatCalc(CalcerFloat first, CalcerFloat second, Operation operation = Operation.Add)
  19. {
  20. this.first = first;
  21. this.second = second;
  22. this.operation = operation;
  23. }
  24. public float value
  25. {
  26. get
  27. {
  28. switch (operation)
  29. {
  30. case Operation.Add:
  31. return first.value + second.value;
  32. case Operation.Sub:
  33. return first.value - second.value;
  34. case Operation.Mul:
  35. return first.value * second.value;
  36. case Operation.Div:
  37. return first.value / second.value;
  38. default:
  39. throw new Exception("Operation not found.");
  40. }
  41. }
  42. }
  43. }
  44. }