Ingredient.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. class Ingredient{
  2. constructor(id, name, category, unitType, unit, parent, specialUnit = undefined, unitSize = undefined){
  3. if(!controller.sanitaryString(name)){
  4. banner.createError("NAME CONTAINS ILLEGAL CHARCTERS");
  5. return false;
  6. }
  7. if(!controller.sanitaryString(category)){
  8. banner.createError("CATEGORY CONTAINS ILLEGAL CHARACTERS");
  9. return false;
  10. }
  11. this._id = id;
  12. this._name = name;
  13. this._category = category;
  14. this._unitType = unitType;
  15. this._unit = unit;
  16. this._parent = parent;
  17. if(specialUnit){
  18. this._specialUnit = specialUnit;
  19. this._unitSize = unitSize;
  20. }
  21. }
  22. get id(){
  23. return this._id;
  24. }
  25. get name(){
  26. return this._name;
  27. }
  28. set name(name){
  29. if(!controller.sanitaryString(name)){
  30. return false;
  31. }
  32. this._name = name;
  33. }
  34. get category(){
  35. return this._category;
  36. }
  37. set category(category){
  38. if(!controller.sanitaryString(category)){
  39. return false;
  40. }
  41. this._category = category;
  42. }
  43. get unitType(){
  44. return this._unitType;
  45. }
  46. get unit(){
  47. return this._unit;
  48. }
  49. set unit(unit){
  50. this._unit = unit;
  51. }
  52. get parent(){
  53. return this._parent;
  54. }
  55. get specialUnit(){
  56. return this._specialUnit;
  57. }
  58. get unitSize(){
  59. return this._unitSize;
  60. }
  61. set unitSize(unitSize){
  62. if(unitSize < 0){
  63. return false;
  64. }
  65. this._unitSize = unitSize;
  66. }
  67. }
  68. module.exports = Ingredient;