Skip to content

Instantly share code, notes, and snippets.

View kingsley-einstein's full-sized avatar
🏠
Working from home

Kingsley Victor kingsley-einstein

🏠
Working from home
View GitHub Profile
@kingsley-einstein
kingsley-einstein / TicTacToe.java
Created April 5, 2018 16:22
A command line Tic-Tac-Toe game implemented with the minimax algorithm
import java.util.*;
//The move class. This will be instantiated with a row and column argument passed based on user input
class Move {
int r;
int c;
Move(int r, int c) {
this.r=r;
this.c=c;
import { User } from '../../../models';
export interface UserState {
data: User | null;
users: User[] | null;
}
export const initialUserState : UserState = {
data: null,
users: null
import { User } from '../../../models';
export interface UserState {
data: User | null;
users: User[] | null;
}
export const initialUserState : UserState = {
data: null,
users: null
import { User } from './User';
export interface Post {
id: number;
title: string;
content: string;
createdAt: Date;
author: User
}
import { Post } from '../../../models';
export interface PostState {
data: Post | null;
posts: Post[] | null;
}
export const initialPostState: PostState = {
data: null,
posts: null
import { Injectable } from '@angular/core';
import { User } from '../../models';
import { PostService } from '../post';
@Injectable()
export class UserService {
public db: User[] = [];
constructor(private postService: PostService) {}
insert(user: User) : void {
import { Injectable } from '@angular/core';
import { Post, User } from '../../models';
let id: number = 1;
@Injectable()
export class PostService {
public db: Post[] = [];
constructor() {}
import { Action } from '@ngrx/store';
import { User } from '../../../models';
export enum UserActionTypes {
LoadUserPing = '[User] Ping To Load User',
LoadUsersPing = '[User] Ping To Load Users',
LoadUser = '[User] Load A User',
LoadUsers = '[User] Load All Users'
}
import { Action } from '@ngrx/store';
import { Post } from '../../../models';
export enum PostActionTypes {
LoadPostPing = '[Post] Ping To Load A Post',
LoadPostsPing = '[Post] Ping To Load All Posts',
LoadPost = '[Post] Load A Post',
LoadPosts = '[Post] Load All Posts'
}
import { UserState, initialUserState } from '../../states';
import { UserActionTypes, UserActionUnion } from '../../actions';
export default (state: UserState = initialUserState, action: UserActionUnion) : UserState => {
switch (action.type) {
case UserActionTypes.LoadUser:
return {
...state,