Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // apply for purchasing new equipment for the company
- var Apply = function(name) {
- this.name = name;
- };
- // application prototype
- Apply.prototype.request = function (amount, dollar) {
- if (!new num().numChecker(amount)) {
- result = "denied";
- }else{
- result = "approved";
- }
- if (!new money().moneyChecker(dollar)) {
- result = "denied";
- }else{
- result = "approved";
- }
- return this.name + " number:" + amount + " price:$" + dollar + " has been " + result + " for purchasing ";
- };
- var num = function() {
- this.numChecker = function(amount) {
- // check the amount of equipment
- if(amount < 10){
- return true;
- }else
- {
- console.log('please contact manager.');
- }
- }
- };
- var money = function() {
- this.moneyChecker = function(dollar) {
- // check the equipment price
- if(dollar < 100){
- return true;
- }else
- {
- console.log('please contact manager.');
- }
- }
- };
- function run() {
- var apply = new Apply('iphone');
- var applyresult = apply.request(1, 2);
- console.log(applyresult);
- };
- run();
Add Comment
Please, Sign In to add comment