A class representing a bookstore with inventory management.
import { Book } from "./Book";import { BookStore } from "./BookStore";// Initialize bookstoreconst bookstore = new BookStore("The Corner Bookshop", "Downtown");// Add inventoryconst book1 = new Book("1984");const book2 = new Book("Pride and Prejudice");bookstore.addToInventory(book1);bookstore.addToInventory(book2);// Check stockconsole.log(`Books in stock: ${bookstore.getInventoryCount()}`);console.log(`Has '1984': ${bookstore.hasBook("1984")}`);console.log(`Store: ${bookstore.name} at ${bookstore.location}`); Copy
import { Book } from "./Book";import { BookStore } from "./BookStore";// Initialize bookstoreconst bookstore = new BookStore("The Corner Bookshop", "Downtown");// Add inventoryconst book1 = new Book("1984");const book2 = new Book("Pride and Prejudice");bookstore.addToInventory(book1);bookstore.addToInventory(book2);// Check stockconsole.log(`Books in stock: ${bookstore.getInventoryCount()}`);console.log(`Has '1984': ${bookstore.hasBook("1984")}`);console.log(`Store: ${bookstore.name} at ${bookstore.location}`);
Inventory management (excluding pricing logic) Copy
Inventory management (excluding pricing logic)
A class representing a bookstore with inventory management.
Example
Example