<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script>
		//工厂模式,继承父类方法,创造不同对象,
		//工厂模式,就是一个封装了创建相似对象的类。
			function PeopleFactory(){
			}
			
			PeopleFactory.prototype = {
				 createFacotry:function(){
				 	throw "this is a baseClass";
				 }
			}
			
			function SubPeopleFactory(){
				PeopleFactory.call(this);
			}
			//------继承-----
			SubPeopleFactory.prototype = new PeopleFactory();
			SubPeopleFactory.prototype.constructor = SubPeopleFactory;
			//------end-------
			//-------重写-----
			SubPeopleFactory.prototype.createFacotry = function(){
				var info = {
					gongRen:function(){
						return "Workers";
					},
					nongMing:function(){
						return "fammer";
					},
					xueSheng:function(){
					   return "student";
					}
				}
			  return info;
			}
			//---------end-----------
			var sp = new SubPeopleFactory();
			var ob = sp.createFacotry()['gongRen']();
			console.log(ob);
		</script>
	</head>
	<body>
	</body>
</html>