Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
Repozitorijs ir arhivēts. Tam var aplūkot failus un to var klonēt, bet nevar iesūtīt jaunas izmaiņas, kā arī atvērt jaunas problēmas/izmaiņu pieprasījumus.

49 rindas
1.2KB

  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. }