From 88ea1e84538bea10b4c833459b5b9f4e9d17b931 Mon Sep 17 00:00:00 2001 From: MarcUs7i <96580944+MarcUs7i@users.noreply.github.com> Date: Sat, 18 Jan 2025 20:04:53 +0100 Subject: [PATCH] added my name --- toh_board.c | 4 ++-- toh_board.h | 31 ++++++++++++++++++++++--------- toh_disk.c | 4 ++-- toh_disk.h | 18 ++++++++++++------ toh_main_driver.c | 4 ++-- toh_solver.c | 9 +++++---- toh_solver.h | 12 ++++++++---- 7 files changed, 53 insertions(+), 29 deletions(-) diff --git a/toh_board.c b/toh_board.c index 3e2b859..f1a9fb3 100644 --- a/toh_board.c +++ b/toh_board.c @@ -1,9 +1,9 @@ /*---------------------------------------------------------- - * HTBLA-Leonding / Class: + * HTBLA-Leonding / Class: 2IHIF * --------------------------------------------------------- * Exercise Number: 09 * Title: Tower of Hanoi Disk ADT implementation - * Author: *//* + * Author: Marc Tismonar * ---------------------------------------------------------- * Description: * Implementation of toh_board.h. diff --git a/toh_board.h b/toh_board.h index 084c1ab..801c93a 100644 --- a/toh_board.h +++ b/toh_board.h @@ -1,9 +1,9 @@ /*---------------------------------------------------------- - * HTBLA-Leonding / Class: + * HTBLA-Leonding / Class: 2IHIF * --------------------------------------------------------- * Exercise Number: 09 * Title: Tower of Hanoi Board / Game - * Author: *//* + * Author: Marc Tismonar * ---------------------------------------------------------- * Description: * The declaration of an Abstract Data Type representing @@ -14,11 +14,22 @@ */ /* == !Include guard and required includes need to be added */ - +#ifndef ___TOH_BOARD_H +#define ___TOH_BOARD_H +#include "toh_disk.h" +#include +#include +#include /** The enumeration of available rods: LEFT, MIDDLE, RIGHT. */ +typedef enum { + LEFT, + MIDDLE, + RIGHT +} Rod; /** Declares type for the 'Tower of Hanoi' board */ +typedef struct TohBoardData* TohBoard; /** * Provides the instance of the 'Tower of Hanoi' board. @@ -26,14 +37,14 @@ * * @return TohBoard The board instance. */ - tb_get_board(); +TohBoard tb_get_board(); /** * Removes all disks from any rod of the given board. * * @param board The board instance in focus. */ - tb_clear_board(); +void tb_clear_board(TohBoard board); /** * Determines whether or not the given board is valid. @@ -42,7 +53,7 @@ * @param board The board to evaluate. * @return If the given board is valid, false otherwise. */ - tb_is_valid(); +bool tb_is_valid(TohBoard board); /** * 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. * @return The removed disk or 0, if no disk was on the rod. */ - tb_pop_disk(); +TohBoard tb_pop_disk(TohBoard board, Rod rodName); /** * 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 * (move is allowed and disk is valid), false otherwise. */ - tb_push_disk(); +bool tb_push_disk(TohBoard board, Rod rodName, TohDisk disk); /** * 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 * index position of the named rod. */ - tb_get_disk(); +TohDisk tb_get_disk(TohBoard board, Rod rodName, unsigned short idx); + +#endif \ No newline at end of file diff --git a/toh_disk.c b/toh_disk.c index 62aa019..5e2527a 100644 --- a/toh_disk.c +++ b/toh_disk.c @@ -1,9 +1,9 @@ /*---------------------------------------------------------- - * HTBLA-Leonding / Class: + * HTBLA-Leonding / Class: 2IHIF * --------------------------------------------------------- * Exercise Number: 09 * Title: Tower of Hanoi Disk ADT Implemenation - * Author: *//* + * Author: Marc Tismonar * ---------------------------------------------------------- * Description: * Implementation of toh_disk.h. diff --git a/toh_disk.h b/toh_disk.h index 14a8507..48c16c6 100644 --- a/toh_disk.h +++ b/toh_disk.h @@ -1,9 +1,9 @@ /*---------------------------------------------------------- - * HTBLA-Leonding / Class: + * HTBLA-Leonding / Class: 2IHIF * --------------------------------------------------------- * Exercise Number: 09 * Title: Tower of Hanoi Disk ADT - * Author: *//* + * Author: Marc Tismonar * ---------------------------------------------------------- * Description: * The declaration of an Abstract Data Type representing @@ -15,7 +15,12 @@ /* == !Include guard and required includes need to be added */ +#ifndef ___TOH_DISK_H +#define ___TOH_DISK_H +#include + /** Declares a disk. */ +typedef struct TohDiskData* TohDisk; /** * Provides the instance of the disk with the given size. @@ -25,7 +30,7 @@ * @return The disk of the given size or 0, * if no such disk is available. */ - td_get_disk(unsigned short ); +TohDisk td_get_disk(unsigned short size); /** * Determines whether or not the given disk is valid. @@ -34,7 +39,7 @@ * @param disk The disk in focus of this ADT. * @return True if the disk is valid, false otherwise. */ - td_is_valid(); +bool td_is_valid(TohDisk disk); /** * Provides the size of the given disk. @@ -42,7 +47,7 @@ * @param disk The disk in focus of this ADT. * @return The size of the disk, if it is valid or 0 otherwise. */ -unsigned short td_get_size(); +unsigned short td_get_size(TohDisk disk); /** * Compares the size of the candidate disk with size of the given disk. @@ -52,5 +57,6 @@ unsigned short td_get_size(); * @return True if the 'smaller_candidate' disk is smaller than the * given disk of this ADT and both disks are valid, false otherwise. */ - td_is_smaller(); +bool td_is_smaller(TohDisk disk, TohDisk smaller_candidate); +#endif \ No newline at end of file diff --git a/toh_main_driver.c b/toh_main_driver.c index 1c24ec9..10b99b9 100644 --- a/toh_main_driver.c +++ b/toh_main_driver.c @@ -1,9 +1,9 @@ /*---------------------------------------------------------- - * HTBLA-Leonding / Klasse: n/a + * HTBLA-Leonding / Klasse: 2IHIF * --------------------------------------------------------- * Exercise Number: 09 * Title: Truth Table - * Author: *//* + * Author: Marc Tismonar * ---------------------------------------------------------- * Description: * Truth Table Generator Application. diff --git a/toh_solver.c b/toh_solver.c index 37ed1d3..61fff3d 100644 --- a/toh_solver.c +++ b/toh_solver.c @@ -1,9 +1,9 @@ /*---------------------------------------------------------- - * HTBLA-Leonding / Class: + * HTBLA-Leonding / Class: 2IHIF * --------------------------------------------------------- * Exercise Number: 09 * Title: Tower of Hanoi Disk ADT implementation - * Author: *//* + * Author: Marc Tismonar * ---------------------------------------------------------- * Description: * Implementation of toh_board.h. @@ -11,6 +11,7 @@ */ /* Includes, definitions and instanciations */ +#include "toh_board.h" /* ========================================================= */ /* Private functions */ @@ -23,7 +24,7 @@ * @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. */ -static ts_move_disk() { +static bool ts_move_disk(Rod source, Rod target) { } @@ -39,7 +40,7 @@ static ts_move_disk() { * @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. */ -static ts_move_stack() { +static bool ts_move_stack(unsigned short size, Rod source, Rod intermediate, Rod target) { } diff --git a/toh_solver.h b/toh_solver.h index cf7f4a2..8651f52 100644 --- a/toh_solver.h +++ b/toh_solver.h @@ -1,9 +1,9 @@ /*---------------------------------------------------------- - * HTBLA-Leonding / Class: + * HTBLA-Leonding / Class: 2IHIF * --------------------------------------------------------- * Exercise Number: 09 * Title: Tower of Hanoi Board / Game - * Author: *//* + * Author: Marc Tismonar * ---------------------------------------------------------- * Description: * The Tower of Hanoi is a mathematical game or puzzle. @@ -21,6 +21,10 @@ */ /* == !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. @@ -32,7 +36,7 @@ * * @param disk_count The number of disks to use. Must be less than 'MAX_DISKS'. */ - ts_init(); +void ts_init(unsigned short disk_count); /** * Solves the puzzle by moving all disks from the left rod to the right rod. @@ -40,6 +44,6 @@ * board was initialized. * */ - ts_solve(); +void ts_solve(); #endif