Package org.scotlandyard.impl.engine

Source Code of org.scotlandyard.impl.engine.UserImpl

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.scotlandyard.impl.engine;

import org.scotlandyard.engine.GameException;
import org.scotlandyard.engine.User;

/**
*
* @author Admin
*/
public class UserImpl implements User {
    private transient final String name,email;
    private transient long lastActivity;
    public UserImpl(final String name,final String email){
        this.name=name;
        this.email=email;
        this.updateLastActivity();
    }

    @Override
    public final void updateLastActivity(){
        this.lastActivity= System.currentTimeMillis();
    }

    @Override
    public final long getLastActivity() {
        return lastActivity;
    }
   
    @Override
    public String getEmail() {
        return email;
    }

    @Override
    public String getName() {
        return name;
    }

    /**
     * prepares a new user and add it to the game engine list of users
     * @param name
     * @param email
     * @return
     * @throws GameException if the user email exists in the engine already
     */
    public static User getNewInstance(final String name,final String email) throws GameException{
      final User user = new UserImpl(name, email);
      GameEngine.instance().loginUser(user);
      return user;
    }
   
    @Override
    public String toString() {
        return "User : "+name +" ["+email+"]";
    }
   
}
TOP

Related Classes of org.scotlandyard.impl.engine.UserImpl

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.