I need to complete tSubinfo and tSectionInfo in data.h in order to be able to save the following info:
In tSubInfo
id : That isthe identifier of the subseccion ( only one character)
subBooks: Vectors that tells us the position where books are in the subsection
totSubBooks: total quantity of books in the subsection
tSectionInfo:
section: Estructure of the type section
secSubs:Vector with all subsections (type tSubInfo) of the section (max 10 sections) which have one book
totSecSubs: total quantity of subsections in the Section
totSecBooks: total quantity of books in the section.
The code needs to go in data.h after /******************** code *********************/
/* Uncomment the practice version you want to run */
#define SIMPLE_VERSION
//#define COMPLETE_VERSION
/* This code ensures that this file is included only once
*/
#ifndef __DATA_H
#define __DATA_H
/* If the constant DATA_H is not defined (ifndef), the code is
added, otherwise, this code is excluded. When the code is added,
the constant is defined, therefore next time this file will be
included it will be defined and no inclusion will be done. */
#define MAX_PATHNAME 256
#define MAX_LINE 512
#define MAX_SECTIONS 10
#define MAX_SECTION_NAME 100
#define MAX_BOOKS 300
#define MAX_SUB 10
#define MAX_BOOK_ISBN 14
#define MAX_BOOK_AUTHOR_CODE 4
#define MAX_BOOK_TITLE 101
/* Definition of a boolean type */
typedef enum {FALSE, TRUE} tBoolean;
/* Definition of the error type. */
typedef enum {OK=1, ERROR=0, ERR_CANNOT_READ=-1,
ERR_CANNOT_WRITE=-2, ERR_MEMORY=-3, ERR_DUPLICATED_ENTRY=-4,
ERR_INVALID_DATA=-5, ERR_ENTRY_NOT_FOUND=-6} tError;
/* Definition of a location */
typedef struct {
char row;
char column;
char shelf;
} tLocation;
/* Definition of a section */
typedef struct {
char id;
char name[MAX_SECTION_NAME];
tLocation init;
} tSection;
/* Table of sections */
typedef struct {
tSection table[MAX_SECTIONS];
int size;
} tSectionTable;
/* Definition of a classification */
typedef struct {
char secId;
char subId;
} tClass;
/* Definition of the book */
typedef struct {
char ISBN[MAX_BOOK_ISBN];
unsigned short year;
tBoolean avail;
tClass clas;
char author[MAX_BOOK_AUTHOR_CODE];
char title[MAX_BOOK_TITLE];
} tBook;
/* Table of books */
typedef struct {
#ifdef SIMPLE_VERSION
tBook table[MAX_BOOKS];
#endif
#ifdef COMPLETE_VERSION
#endif
int size;
} tBookTable;
/* Definition of the application data structure */
typedef struct {
/* Path where data will be stored */
char path[MAX_PATHNAME];
/* sections table */
tSectionTable sections;
/* Books table */
tBookTable books;
} tAppData;
/******************** code *********************/
/* Books of a class */
typedef struct {
char id;
/* Table of books of the subsection */
#ifdef SIMPLE_VERSION
#endif
#ifdef COMPLETE_VERSION
#endif
} tSubInfo;
/* Classes of a section */
typedef struct {
unsigned int totSecSubs;
} tSectionInfo;
#endif /*__DATA_H*/
note: i posted data.h and did according to your requirements
/* Uncomment the practice version you want to run */ #define SIMPLE_VERSION //#define COMPLETE_VERSION /* This code ensures that this file is included only once */ #ifndef __DATA_H #define __DATA_H /* If the constant DATA_H is not defined (ifndef), the code is added, otherwise, this code is excluded. When the code is added, the constant is defined, therefore next time this file will be included it will be defined and no inclusion will be done. */ #define MAX_PATHNAME 256 #define MAX_LINE 512 #define MAX_SECTIONS 10 #define MAX_SECTION_NAME 100 #define MAX_BOOKS 300 #define MAX_SUB 10 #define MAX_BOOK_ISBN 14 #define MAX_BOOK_AUTHOR_CODE 4 #define MAX_BOOK_TITLE 101 /* Definition of a boolean type */ typedef enum {FALSE, TRUE} tBoolean; /* Definition of the error type. */ typedef enum {OK=1, ERROR=0, ERR_CANNOT_READ=-1, ERR_CANNOT_WRITE=-2, ERR_MEMORY=-3, ERR_DUPLICATED_ENTRY=-4, ERR_INVALID_DATA=-5, ERR_ENTRY_NOT_FOUND=-6} tError; /* Definition of a location */ typedef struct { char row; char column; char shelf; } tLocation; /* Definition of a section */ typedef struct { char id; char name[MAX_SECTION_NAME]; tLocation init; } tSection; /* Table of sections */ typedef struct { tSection table[MAX_SECTIONS]; int size; } tSectionTable; /* Definition of a classification */ typedef struct { char secId; char subId; } tClass; /* Definition of the book */ typedef struct { char ISBN[MAX_BOOK_ISBN]; unsigned short year; tBoolean avail; tClass clas; char author[MAX_BOOK_AUTHOR_CODE]; char title[MAX_BOOK_TITLE]; } tBook; /* Table of books */ typedef struct { #ifdef SIMPLE_VERSION tBook table[MAX_BOOKS]; #endif #ifdef COMPLETE_VERSION /******************** PR2 - EX6B ********************/ tBook *table; #endif int size; } tBookTable; /* Definition of the application data structure */ typedef struct { /* Path where data will be stored */ char path[MAX_PATHNAME]; /* sections table */ tSectionTable sections; /* Books table */ tBookTable books; } tAppData; /******************** PR2 - EX2 *********************/ /* Books of a class */ typedef struct { /* Table of books of the subsection */ #ifdef SIMPLE_VERSION char id; int subBooks[MAX_BOOKS]; unsigned int totSubBooks; #endif #ifdef COMPLETE_VERSION char id; int *subBooks[MAX_BOOKS]; unsigned int totSubBooks; /******************** PR2 - EX6A ********************/ #endif } tSubInfo; /* Classes of a section */ typedef struct { tSection section; tSubInfo secSubs[MAX_SUB]; unsigned int totSecSubs; unsigned int totSecBooks; } tSectionInfo; #endif /*__DATA_H*/
I need to complete tSubinfo and tSectionInfo in data.h in order to be able to save...
Using the provided table interface table.h and the sample linked list code linkedList.c, complete an implementation of the Table ADT. Make sure that you apply the concepts of design by contract (DbC) to your implementation. Once you have fully implemented the table, create a main.c file that implements a testing framework for your table. Your table implementation must ensure that values inserted are unique, and internally sorted within a linked list. table.h #ifndef _TABLE_H #define _TABLE_H //----------------------------------------------------------------------------- // CONSTANTS AND...
I need help in my C++ code regarding outputting the enums in string chars. I created a switch statement for the enums in order to output words instead of their respective enumerated values, but an error came up regarding a "cout" operator on my "Type of Item" line in my ranged-based for loop near the bottom of the code. I tried casting "i.type" to both "i.GroceryItem::Section::type" and "i.Section::type", but neither worked. Simply put, if a user inputs 1 as their...
I JUST NEED HELP WITH DISPLAY PART!
please help!
thanks in advance
// This function saves the array of structures to file. It is already implemented for you.
// You should understand how this code works so that you know how to use it for future assignments.
void save(char* fileName)
{
FILE* file;
int i;
file = fopen(fileName, "wb");
fwrite(&count, sizeof(count), 1, file);
for (i = 0; i < count; i++)
{
fwrite(list[i].name, sizeof(list[i].name), 1, file);
fwrite(list[i].class_standing, sizeof(list[i].class_standing), 1, file);...
Hey everyone, I need help making a function with this directions
with C++ Language.
Can you guys use code like printf and fscanf without iostream or
fstream because i havent study that yet.
Thanks.
Directions: Write a function declaration and definition for the char* function allocCat. This function should take in as a parameter a const Words pointer (Words is a defined struct) The function should allocate exactly enough memory for the concatenation of all of the strings in the...
This is a simple C++ class using inheritance, I have trouble getting the program to work. I would also like to add ENUM function to the class TeachingAssistant(Derived class) which is a subclass of Student(Derived Class) which is also a subclass of CourseMember(Base Class). The TeachingAssistant class uses an enum (a user-defined data type) to keep track of the specific role the TA has: enum ta_role {LAB_ASSISTANT, LECTURE_ASSISTANT, BOTH}; You may assume for initialization purposes that the default role is...
Hello! I'm posting this program that is partially completed if someone can help me out, I will give you a good rating! Thanks, // You are given a partially completed program that creates a list of employees, like employees' record. // Each record has this information: employee's name, supervisors's name, department of the employee, room number. // The struct 'employeeRecord' holds information of one employee. Department is enum type. // An array of structs called 'list' is made to hold...
Hello, I am having trouble with a problem in my C language class. I am trying to make a program with the following requirements: 1. Use #define to define MAX_SIZE1 as 20, and MAX_SIZE2 as 10 2. Use typedef to define the following struct type: struct { char name[MAX_SIZE1]; int scores[MAX_SIZE2]; } 3. The program accepts from the command line an integer n (<= 30) as the number of students in the class. You may assume that the...
// =================== Support Code ================= // Queue // // // // - Implement each of the functions to create a working circular queue. // - Do not change any of the function declarations // - (i.e. queue_t* create_queue(unsigned int _capacity) should not have additional arguments) // - You should not have any 'printf' statements in your queue functions. // - (You may consider using these printf statements to debug, but they should be removed from your final version) // ==================================================...
This is for my c++ class and I would really appreciate the help, Thank you! Complete the definitions of the functions for the ConcessionStand class in the ConcessionStand.cpp file. The class definition and function prototypes are in the provided ConcessionStand.h header file. A testing program is in the provided main.cpp file. You don’t need to change anything in ConcessionStand.h or main.cpp, unless you want to play with different options in the main.cpp program. ___________________ Main.cpp ____________________ #include "ConcessionStand.h" #include <iostream>...
Can you help with this C programming question. I have provided
the skeleton code below along with the Stack/Data/Process Class for
you to see/reference. Along with the Stack/Data type
definition.
**SKELTON CODE**
#include
#include
#include
Stack* concat_stack(Stack *s1, Stack *s2) {
//your code here
return NULL;
}
**STACK CLASS FOR YOU TO REFERENCE**
#include
#include
#include
#include
Stack* create_stack(int stack_capacity) {
Stack *s = (Stack*) malloc(sizeof(Stack));
if (stack_capacity < 1) {
fprintf(stderr, "Error(create_stack): invalid capacity, set to
10\n");
s->capacity =...