Data Structures Program (C Program only) ADT Need Complete code for Full points
ID: 3537304 • Letter: D
Question
Data Structures Program (C Program only) ADT Need Complete code for Full points
Your college bookstore has hired you as a summer intern to design a textbook inventory system. It is to include the following major processes.
a. Ordering textbooks, b. Receiving textbooks, c. Determining retail price, d. Pricing used textbooks, e. Determining quantity on hand, f. Recording textbook sales, g. Recording textbook returns
Write the abstract data type interface (i.e. header file) for the inventory system. Each function prototype should include name, parameters, purpose, preconditions, return value types. You may add additional functions as required by your analysis.
You do not need to write the implementation file for your abstract data type interface.
Explanation / Answer
// Enum to indicate the book's condition.
// Can be expanded to include e-books, etc.
enum BookCondition {
BookConditionNew = 0,
BookConditionUsed = 1
};
// Data structure to represent a Book type.
struct Book {
unsigned long isbn_10; // Unique ISBN 10 identifier
unsigned long isbn_13; // Unique ISBN 13 identifier
char title[500]; // Title of the book
// Authors, upto 5.
struct {
char firstname[150];
char lastname[150];
} authors[5];
char publisher[250]; // Publisher info
int edition;
float price; // Price in USD
BookCondition condition; // New or used book
int quantityAvailable;
};
// Data structure to rerpresent an item in the order
// An order is a composition of multiple OrderItems
struct OrderItem {
struct Book * book; // Reference to the book ordered
int quantity; // Quantity of the above condition requested
struct OrderItem * nextItem;
};
// enum for the current status of the order
enum OrderStatus {
OrderStatusProcessing,
OrderStatusShipped,
OrderStatusDelivered,
OrderStatusCancelled,
OrderStatusReturned
};
struct Order {
unsigned int id; // Unique identifier of the order
struct OrderItem * items; // Reference to a list of OrderItems
unsigned long date; // UNIX timestamp used for order date.
OrderStatus status;
struct {
char firstname[250];
char lastname[250];
char address[500];
} shippingTo;
struct {
char firstname[250];
char lastname[250];
char address[500];
} billingTo;
};
// Sample collections to illustrate the usage
struct Book books[100];
struct Orders orders[100];
/*------------------- Ordering Text Books -----------------------*/
// function adds the order to the global list of orders and assigns a unique id.
// Return 1 on success, 0 on failure.
int placeOrder(Order * order);
/*------------------ Receiving Text Books -----------------------*/
// function adds the quantity of the given book condition in the book structure.
// function shall create & add a new Book struct in case it is not present in the list.
// returns the new quantity.
int addBookStock(char * ISBN, BookCondition condition, int quantityToAdd);
/*---------------- Determining Retail Price ---------------------*/
// Determine the price of the book, using ISBN number. 10/13 is determined using length
// Returns the price from a web service/file.
float getRetailPrice(char * ISBN);
/*---------------- Determining Quantity in hand ---------------------*/
// Function iterates through the list of books and determines quantity.
// Returns the quantity of books available.
int getQuantityAvailable(char * ISBN, BookCondition condition);
/*------------------- Recording Book Sales --------------------------*/
// Function displays the total sales by iterating the order list and
// taking into account the shipped and delivered orders only.
void displaySales();
/*---------------- Recording Text Book Returns ---------------------*/
// Function displays the Returns by taking into account the orders
// with status Returned.
void displayReturns();
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.