Skip to content

Commit

Permalink
Node.h, Node.cpp: Added header file for class Node
Browse files Browse the repository at this point in the history
Added Node.h to contain class declaration, constructor and method
for class Node. Node.cpp yet to be filled pending clarification on
implementation.

Signed-off-by: Rohit Das <[email protected]>
  • Loading branch information
mouri11 committed Dec 24, 2017
1 parent 0f2ed27 commit 9729438
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 24 deletions.
25 changes: 1 addition & 24 deletions cpp/NPuzzleSolverUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,7 @@

#include <vector>
#include <iostream>

class Node {
Node* parent;
std::vector< std::vector<int> > state;

int manhattan_distance;

/* Position of the Blank spot */
int x, y;

public:
Node() {}
Node(Node* parent,
const std::vector< std::vector<int> >&state,
int manhattan_distance) {
this->parent = parent;
this->state = state;
this->manhattan_distance = manhattan_distance;
}

int get_manhattan_distance();
Node* get_parent();
void print_node();
};
#include <cpp/Node.h>

class NPuzzleSolver {
public:
Expand Down
19 changes: 19 additions & 0 deletions cpp/Node.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright 2017 Bytes Club
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/

#include <iostream>
#include "Node.h"
47 changes: 47 additions & 0 deletions cpp/Node.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright 2017 Bytes Club
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/

#ifndef CPP_NODE_H_
#define CPP_NODE_H_

#include <vector>
#include <iostream>

class Node {
Node* parent;
std::vector< std::vector<int> > state;
int manhattan_distance;

/*Position of blank spot*/
int x,y;

public:
Node() {}
Node (Node* parent,
const std::vector< std::vector<int> >& state,
int manhattan_distance) {
this->parent = parent;
this->state = state;
this->manhattan_distance = manhattan_distance;
}

int get_manhattan_distance();
Node* get_parent();
void print_node();
}

#endif //CPP_NODE_H_

0 comments on commit 9729438

Please sign in to comment.