added my name
This commit is contained in:
parent
049a40aaa0
commit
88ea1e8453
7 changed files with 53 additions and 29 deletions
|
|
@ -1,9 +1,9 @@
|
||||||
/*----------------------------------------------------------
|
/*----------------------------------------------------------
|
||||||
* HTBLA-Leonding / Class: <your class>
|
* HTBLA-Leonding / Class: 2IHIF
|
||||||
* ---------------------------------------------------------
|
* ---------------------------------------------------------
|
||||||
* Exercise Number: 09
|
* Exercise Number: 09
|
||||||
* Title: Tower of Hanoi Disk ADT implementation
|
* Title: Tower of Hanoi Disk ADT implementation
|
||||||
* Author: */<your name>/*
|
* Author: Marc Tismonar
|
||||||
* ----------------------------------------------------------
|
* ----------------------------------------------------------
|
||||||
* Description:
|
* Description:
|
||||||
* Implementation of toh_board.h.
|
* Implementation of toh_board.h.
|
||||||
|
|
|
||||||
31
toh_board.h
31
toh_board.h
|
|
@ -1,9 +1,9 @@
|
||||||
/*----------------------------------------------------------
|
/*----------------------------------------------------------
|
||||||
* HTBLA-Leonding / Class: <your class>
|
* HTBLA-Leonding / Class: 2IHIF
|
||||||
* ---------------------------------------------------------
|
* ---------------------------------------------------------
|
||||||
* Exercise Number: 09
|
* Exercise Number: 09
|
||||||
* Title: Tower of Hanoi Board / Game
|
* Title: Tower of Hanoi Board / Game
|
||||||
* Author: */<your name>/*
|
* Author: Marc Tismonar
|
||||||
* ----------------------------------------------------------
|
* ----------------------------------------------------------
|
||||||
* Description:
|
* Description:
|
||||||
* The declaration of an Abstract Data Type representing
|
* The declaration of an Abstract Data Type representing
|
||||||
|
|
@ -14,11 +14,22 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* == !Include guard and required includes need to be added */
|
/* == !Include guard and required includes need to be added */
|
||||||
|
#ifndef ___TOH_BOARD_H
|
||||||
|
#define ___TOH_BOARD_H
|
||||||
|
#include "toh_disk.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
/** The enumeration of available rods: LEFT, MIDDLE, RIGHT. */
|
/** The enumeration of available rods: LEFT, MIDDLE, RIGHT. */
|
||||||
|
typedef enum {
|
||||||
|
LEFT,
|
||||||
|
MIDDLE,
|
||||||
|
RIGHT
|
||||||
|
} Rod;
|
||||||
|
|
||||||
/** Declares type for the 'Tower of Hanoi' board */
|
/** Declares type for the 'Tower of Hanoi' board */
|
||||||
|
typedef struct TohBoardData* TohBoard;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the instance of the 'Tower of Hanoi' board.
|
* Provides the instance of the 'Tower of Hanoi' board.
|
||||||
|
|
@ -26,14 +37,14 @@
|
||||||
*
|
*
|
||||||
* @return TohBoard The board instance.
|
* @return TohBoard The board instance.
|
||||||
*/
|
*/
|
||||||
<type> tb_get_board();
|
TohBoard tb_get_board();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all disks from any rod of the given board.
|
* Removes all disks from any rod of the given board.
|
||||||
*
|
*
|
||||||
* @param board The board instance in focus.
|
* @param board The board instance in focus.
|
||||||
*/
|
*/
|
||||||
<type> tb_clear_board(<params>);
|
void tb_clear_board(TohBoard board);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines whether or not the given board is valid.
|
* Determines whether or not the given board is valid.
|
||||||
|
|
@ -42,7 +53,7 @@
|
||||||
* @param board The board to evaluate.
|
* @param board The board to evaluate.
|
||||||
* @return If the given board is valid, false otherwise.
|
* @return If the given board is valid, false otherwise.
|
||||||
*/
|
*/
|
||||||
<type> tb_is_valid(<params>);
|
bool tb_is_valid(TohBoard board);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the top-most disk of the given rod and removes it from this rod.
|
* Provides the top-most disk of the given rod and removes it from this rod.
|
||||||
|
|
@ -51,7 +62,7 @@
|
||||||
* @param rodName The rod from which the disk shall be taken and removed.
|
* @param rodName The rod from which the disk shall be taken and removed.
|
||||||
* @return The removed disk or 0, if no disk was on the rod.
|
* @return The removed disk or 0, if no disk was on the rod.
|
||||||
*/
|
*/
|
||||||
<type> tb_pop_disk(<params>);
|
TohBoard tb_pop_disk(TohBoard board, Rod rodName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies the given disk to the given rod, if this
|
* Applies the given disk to the given rod, if this
|
||||||
|
|
@ -63,7 +74,7 @@
|
||||||
* @return True if the disk could be legally placed on the rod
|
* @return True if the disk could be legally placed on the rod
|
||||||
* (move is allowed and disk is valid), false otherwise.
|
* (move is allowed and disk is valid), false otherwise.
|
||||||
*/
|
*/
|
||||||
<type> tb_push_disk(<params>);
|
bool tb_push_disk(TohBoard board, Rod rodName, TohDisk disk);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the disk from the named rod at the given position.
|
* Provides the disk from the named rod at the given position.
|
||||||
|
|
@ -75,4 +86,6 @@
|
||||||
* @return The addressed disk or 0, if not disk is located on the
|
* @return The addressed disk or 0, if not disk is located on the
|
||||||
* index position of the named rod.
|
* index position of the named rod.
|
||||||
*/
|
*/
|
||||||
<type> tb_get_disk(<params>);
|
TohDisk tb_get_disk(TohBoard board, Rod rodName, unsigned short idx);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
/*----------------------------------------------------------
|
/*----------------------------------------------------------
|
||||||
* HTBLA-Leonding / Class: <your class>
|
* HTBLA-Leonding / Class: 2IHIF
|
||||||
* ---------------------------------------------------------
|
* ---------------------------------------------------------
|
||||||
* Exercise Number: 09
|
* Exercise Number: 09
|
||||||
* Title: Tower of Hanoi Disk ADT Implemenation
|
* Title: Tower of Hanoi Disk ADT Implemenation
|
||||||
* Author: */<your name>/*
|
* Author: Marc Tismonar
|
||||||
* ----------------------------------------------------------
|
* ----------------------------------------------------------
|
||||||
* Description:
|
* Description:
|
||||||
* Implementation of toh_disk.h.
|
* Implementation of toh_disk.h.
|
||||||
|
|
|
||||||
18
toh_disk.h
18
toh_disk.h
|
|
@ -1,9 +1,9 @@
|
||||||
/*----------------------------------------------------------
|
/*----------------------------------------------------------
|
||||||
* HTBLA-Leonding / Class: <your class>
|
* HTBLA-Leonding / Class: 2IHIF
|
||||||
* ---------------------------------------------------------
|
* ---------------------------------------------------------
|
||||||
* Exercise Number: 09
|
* Exercise Number: 09
|
||||||
* Title: Tower of Hanoi Disk ADT
|
* Title: Tower of Hanoi Disk ADT
|
||||||
* Author: */<your name>/*
|
* Author: Marc Tismonar
|
||||||
* ----------------------------------------------------------
|
* ----------------------------------------------------------
|
||||||
* Description:
|
* Description:
|
||||||
* The declaration of an Abstract Data Type representing
|
* The declaration of an Abstract Data Type representing
|
||||||
|
|
@ -15,7 +15,12 @@
|
||||||
|
|
||||||
/* == !Include guard and required includes need to be added */
|
/* == !Include guard and required includes need to be added */
|
||||||
|
|
||||||
|
#ifndef ___TOH_DISK_H
|
||||||
|
#define ___TOH_DISK_H
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
/** Declares a disk. */
|
/** Declares a disk. */
|
||||||
|
typedef struct TohDiskData* TohDisk;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the instance of the disk with the given size.
|
* Provides the instance of the disk with the given size.
|
||||||
|
|
@ -25,7 +30,7 @@
|
||||||
* @return The disk of the given size or 0,
|
* @return The disk of the given size or 0,
|
||||||
* if no such disk is available.
|
* if no such disk is available.
|
||||||
*/
|
*/
|
||||||
<type> td_get_disk(unsigned short <params>);
|
TohDisk td_get_disk(unsigned short size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines whether or not the given disk is valid.
|
* Determines whether or not the given disk is valid.
|
||||||
|
|
@ -34,7 +39,7 @@
|
||||||
* @param disk The disk in focus of this ADT.
|
* @param disk The disk in focus of this ADT.
|
||||||
* @return True if the disk is valid, false otherwise.
|
* @return True if the disk is valid, false otherwise.
|
||||||
*/
|
*/
|
||||||
<type> td_is_valid(<params>);
|
bool td_is_valid(TohDisk disk);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the size of the given disk.
|
* Provides the size of the given disk.
|
||||||
|
|
@ -42,7 +47,7 @@
|
||||||
* @param disk The disk in focus of this ADT.
|
* @param disk The disk in focus of this ADT.
|
||||||
* @return The size of the disk, if it is valid or 0 otherwise.
|
* @return The size of the disk, if it is valid or 0 otherwise.
|
||||||
*/
|
*/
|
||||||
unsigned short td_get_size(<params>);
|
unsigned short td_get_size(TohDisk disk);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compares the size of the candidate disk with size of the given disk.
|
* Compares the size of the candidate disk with size of the given disk.
|
||||||
|
|
@ -52,5 +57,6 @@ unsigned short td_get_size(<params>);
|
||||||
* @return True if the 'smaller_candidate' disk is smaller than the
|
* @return True if the 'smaller_candidate' disk is smaller than the
|
||||||
* given disk of this ADT and both disks are valid, false otherwise.
|
* given disk of this ADT and both disks are valid, false otherwise.
|
||||||
*/
|
*/
|
||||||
<type> td_is_smaller(<params>);
|
bool td_is_smaller(TohDisk disk, TohDisk smaller_candidate);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
/*----------------------------------------------------------
|
/*----------------------------------------------------------
|
||||||
* HTBLA-Leonding / Klasse: n/a
|
* HTBLA-Leonding / Klasse: 2IHIF
|
||||||
* ---------------------------------------------------------
|
* ---------------------------------------------------------
|
||||||
* Exercise Number: 09
|
* Exercise Number: 09
|
||||||
* Title: Truth Table
|
* Title: Truth Table
|
||||||
* Author: */<your name>/*
|
* Author: Marc Tismonar
|
||||||
* ----------------------------------------------------------
|
* ----------------------------------------------------------
|
||||||
* Description:
|
* Description:
|
||||||
* Truth Table Generator Application.
|
* Truth Table Generator Application.
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
/*----------------------------------------------------------
|
/*----------------------------------------------------------
|
||||||
* HTBLA-Leonding / Class: <your class>
|
* HTBLA-Leonding / Class: 2IHIF
|
||||||
* ---------------------------------------------------------
|
* ---------------------------------------------------------
|
||||||
* Exercise Number: 09
|
* Exercise Number: 09
|
||||||
* Title: Tower of Hanoi Disk ADT implementation
|
* Title: Tower of Hanoi Disk ADT implementation
|
||||||
* Author: */<your name>/*
|
* Author: Marc Tismonar
|
||||||
* ----------------------------------------------------------
|
* ----------------------------------------------------------
|
||||||
* Description:
|
* Description:
|
||||||
* Implementation of toh_board.h.
|
* Implementation of toh_board.h.
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Includes, definitions and instanciations */
|
/* Includes, definitions and instanciations */
|
||||||
|
#include "toh_board.h"
|
||||||
|
|
||||||
/* ========================================================= */
|
/* ========================================================= */
|
||||||
/* Private functions */
|
/* Private functions */
|
||||||
|
|
@ -23,7 +24,7 @@
|
||||||
* @param target The rod to which the disk shall be moved.
|
* @param target The rod to which the disk shall be moved.
|
||||||
* @return True if the move was successful and according to the rules, false otherwise.
|
* @return True if the move was successful and according to the rules, false otherwise.
|
||||||
*/
|
*/
|
||||||
static <type> ts_move_disk(<params>) {
|
static bool ts_move_disk(Rod source, Rod target) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -39,7 +40,7 @@ static <type> ts_move_disk(<params>) {
|
||||||
* @param target The rod to which the disks shall be moved.
|
* @param target The rod to which the disks shall be moved.
|
||||||
* @return True if the move was successful and according to the rules, false otherwise.
|
* @return True if the move was successful and according to the rules, false otherwise.
|
||||||
*/
|
*/
|
||||||
static <type> ts_move_stack(<params>) {
|
static bool ts_move_stack(unsigned short size, Rod source, Rod intermediate, Rod target) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
12
toh_solver.h
12
toh_solver.h
|
|
@ -1,9 +1,9 @@
|
||||||
/*----------------------------------------------------------
|
/*----------------------------------------------------------
|
||||||
* HTBLA-Leonding / Class: <your class>
|
* HTBLA-Leonding / Class: 2IHIF
|
||||||
* ---------------------------------------------------------
|
* ---------------------------------------------------------
|
||||||
* Exercise Number: 09
|
* Exercise Number: 09
|
||||||
* Title: Tower of Hanoi Board / Game
|
* Title: Tower of Hanoi Board / Game
|
||||||
* Author: */<your name>/*
|
* Author: Marc Tismonar
|
||||||
* ----------------------------------------------------------
|
* ----------------------------------------------------------
|
||||||
* Description:
|
* Description:
|
||||||
* The Tower of Hanoi is a mathematical game or puzzle.
|
* The Tower of Hanoi is a mathematical game or puzzle.
|
||||||
|
|
@ -21,6 +21,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* == !Include guard and required includes need to be added */
|
/* == !Include guard and required includes need to be added */
|
||||||
|
#ifndef ___TOH_SOLVER_H
|
||||||
|
#define ___TOH_SOLVER_H
|
||||||
|
#include "toh_board.h"
|
||||||
|
#include "toh_disk.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initials a 'Tower of Hanoi' board with the given number of disks.
|
* Initials a 'Tower of Hanoi' board with the given number of disks.
|
||||||
|
|
@ -32,7 +36,7 @@
|
||||||
*
|
*
|
||||||
* @param disk_count The number of disks to use. Must be less than 'MAX_DISKS'.
|
* @param disk_count The number of disks to use. Must be less than 'MAX_DISKS'.
|
||||||
*/
|
*/
|
||||||
<type> ts_init(<params>);
|
void ts_init(unsigned short disk_count);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Solves the puzzle by moving all disks from the left rod to the right rod.
|
* Solves the puzzle by moving all disks from the left rod to the right rod.
|
||||||
|
|
@ -40,6 +44,6 @@
|
||||||
* board was initialized.
|
* board was initialized.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
<type> ts_solve();
|
void ts_solve();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue