fork download
  1. 'use strict';
  2.  
  3.  
  4. var small = {
  5. price: 50,
  6. cl: 20,
  7. };
  8.  
  9. var big = {
  10. price: 100,
  11. cl: 40,
  12. }
  13.  
  14.  
  15. var Staff = function(price, cl) {
  16. this.price = price;
  17. this.cl = cl;
  18. };
  19.  
  20. var Hamburger = function(price, cl, stuff, flavoring) {
  21.  
  22. if (!((price == small.price && cl ==small.cl) || (price == big.price && cl == big.cl))) {
  23. throw 'Hanburger type was not recognized';
  24. }
  25.  
  26. this.price = price;
  27. this.cl = cl;
  28. this.add_stuff(stuff);
  29.  
  30. if (flavoring) {
  31. this.add_stuff(flavoring);
  32. }
  33.  
  34. };
  35.  
  36.  
  37. Hamburger.prototype.toString = function() {
  38. return 'Price: ' + this.price + ' Cl: ' + this.cl;
  39. };
  40.  
  41. Hamburger.prototype.add_stuff = function(stuff) {
  42. this.price += stuff.price;
  43. this.cl += stuff.cl;
  44. };
  45.  
  46.  
  47. function createHumburger(size, stuff, extra_stuff) {
  48. var h = new Hamburger(size.price, size.cl, stuff, extra_stuff);
  49. console.log(h);
  50. }
  51.  
  52. var s = new Staff(10, 20);
  53. var f = new Staff(15, 0);
  54. createHumburger(small, s, f);
  55.  
  56.  
  57. // http://i...content-available-to-author-only...e.com/4pMXyV
  58. // Посоны, проверьте про гамбургеры задание. И еще скажите как реализовать функцию bind. Я не втыкаю что-то.
  59.  
Runtime error #stdin #stdout #stderr 0.01s 29760KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
prog.js:49:4 ReferenceError: console is not defined