22

来源:互联网 发布:only的淘宝代购靠谱吗 编辑:程序博客网 时间:2024/06/08 04:13
//Javascript Code : User add/delete informationvar member = function(userId, name, sex, age, password, remark){this.userId = userId;this.name = name;this.sex = sex;this.age = age;this.password = password;this.remark = remark;};member.prototype = {addInfo:function(userId, infoBody, date){//addInfo(userId, infoBody, date);},deleteInfo:function(infoId){//deleteInfo(infoId);},addComment:function(userId, commentBody, date){//addComment(userId, commentBody, date);},deleteComment:function(commentId){//deleteComment(commentId)''},addLike:function(userId, infoId){//addLike(userId, infoId);},deleteLike:function(likeId){//deleteLike(likeId);}}function user(){member.call(this);this.isAdmin = false;}user.prototype = new member();function admin(name, sex, age, password, isAdmin, remark){member.call(this);this.isAdmin = true;}admin.prototype = new member();admin.prototype.addUser = function(userName, userPwd){//addUser(userName, userPwd);}admin.prototype.deleteUser = function(userId){//deleteUser(userId);}//create user & adminvar User = new user(1, 'user', 1, 22, '123456', 0, 'this is a normal user.');var Admin = new admin(2 , 'admin', 1, 22, '123456', 0, 'this is a super admin.');//addinfo//if success, console.log('this is a information by user at 2014-12-10');User.addInfo(1, 'this is a information', new Date('2014-12-10'));//addComment//if success, console.log('this is a comment by user at 2014-12-10');User.addComment(1, 'this is a comment', new Date('2014-12-10'));//deleteLike//if success, console.log('the likeId 2 has been delete.');User.deleteLike(2);//deleteUser//if success, console.log('the userId 1 has been deleted by admin.');admin.deleteUser(1);

0 0
原创粉丝点击