标签:
var GFTest={}; (function($){ var RICH2=function(){ }; var YOU=function(parames){ this.hasCar=parames[0]; this.hasHouse=parames[1]; this.loc=parames[2]; this.monthMoney=parames[3]; this.havedMoney=parames[4]; this.gfYear=parames[5]; }; var testYourGF=function(){ } testYourGF.houseSize={ common:80 } testYourGF.carPrice={ common:120000 } testYourGF.hoursePri={ "郑州":9000, "北京":50000, "上海":40000, "广州":30000 }; testYourGF.lifePri={ "郑州":3000, "北京":5000, "上海":5000, "广州":4000 }; testYourGF.flg2result={ 0:"你这富二代,她应该会嫁给你。", 1:"她会嫁给你,你已经有车有房。", 2:"她可能会嫁给你,你十年内买了房,但没买车。", 3:"她应该会嫁给你,你是人生赢家,十年买车买房。", 4:"她十年中不会嫁给你,你十年白干了,车房一个都买不起。", }; testYourGF.prototype={ init:function(you) { console.info(you); if (you instanceof RICH2) { return testYourGF.flg2result[0]; }else if(you.hasCar&&you.hasHouse){ return testYourGF.flg2result[1]; }else{ var rel=this.testTrueLove(you); return testYourGF.flg2result[rel]; } }, testTrueLove:function(you){ for(i=1;i<11;i++){ var rel=this.testHouseGoal(you,i); if(!rel){ continue; }else{ return rel; } } return 4; }, testHouseGoal:function(you,j){ return (you.havedMoney+(you.monthMoney-testYourGF.lifePri[you.loc])*j*12)>testYourGF.hoursePri[you.loc]*testYourGF.houseSize.common*0.3?this.testCarGoal(you,j):false }, testCarGoal:function(you,j){ return (you.havedMoney+(you.monthMoney-testYourGF.lifePri[you.loc])*j*12)>testYourGF.carPrice.common*0.3?"3":j==10?"2":false; } } $.merryOrLive=function(rich2,hasCar,hasHouse,location,monthMoney,havedMoney,gfYear){ var parames=[].slice.call(arguments); if(rich2){ var you= new RICH2(); }else{ var you= new YOU(parames.slice(1)); } var test=new testYourGF(); return test.init(you); } })(GFTest); /*用法 * 参数分别是,是否富二代,是否买车,是否买房,你工作地点,你月薪,你存款,你女友交往时间年 * */ // alert(GFTest.merryOrLive(false,false,false,"郑州","5000","100000",10));
标签:
原文地址:http://www.cnblogs.com/ecmasea/p/5663451.html