Guest User

Untitled

a guest
Nov 16th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. // apply for purchasing new equipment for the company
  2. var Apply = function(name) {
  3. this.name = name;
  4. };
  5.  
  6. // application prototype
  7. Apply.prototype.request = function (amount, dollar) {
  8. if (!new num().numChecker(amount)) {
  9. result = "denied";
  10. }else{
  11. result = "approved";
  12. }
  13. if (!new money().moneyChecker(dollar)) {
  14. result = "denied";
  15. }else{
  16. result = "approved";
  17. }
  18.  
  19. return this.name + " number:" + amount + " price:$" + dollar + " has been " + result + " for purchasing ";
  20.  
  21. };
  22.  
  23.  
  24. var num = function() {
  25. this.numChecker = function(amount) {
  26. // check the amount of equipment
  27. if(amount < 10){
  28. return true;
  29. }else
  30. {
  31. console.log('please contact manager.');
  32. }
  33. }
  34. };
  35.  
  36. var money = function() {
  37. this.moneyChecker = function(dollar) {
  38. // check the equipment price
  39. if(dollar < 100){
  40. return true;
  41. }else
  42. {
  43. console.log('please contact manager.');
  44. }
  45. }
  46. };
  47.  
  48.  
  49. function run() {
  50. var apply = new Apply('iphone');
  51. var applyresult = apply.request(1, 2);
  52. console.log(applyresult);
  53. };
  54.  
  55. run();
Add Comment
Please, Sign In to add comment