Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C#: For today's lab you will be creating a store inventory management system. Your program will have to have the following elements. It should

In C#:

For today's lab you will be creating a store inventory management system. Your program will have to have the following elements. It should allow any number of customers to shop at the store using names to identify each one. The user should be able to select which one is the current customer. The system must contain a list of at least 50 items (repeats are allowed) that can be purchased by the customers.

For a customer to make a purchase they must transfer the items they wish to buy to their own shopping cart. (A Shopping cart list should be maintained for each customer). The user should be able to switch between customers without losing the contents of each customer's cart. The user can select complete purchase and will be presented with a total for that users purchases. Customers should be able to remove items from their cart and return them to the stores inventory. . A customers cart should be removed after her/his purchase is complete.

A log class should be set up like CE04 except this version should write the messages to a file instead of the console window. Every time the current customer is changed the name of the new customer should be logged. Every time an item moves to or from a shopping cart the item name and new location should be logged. When a purchase is completed the customer name and total should be logged.

NOTE: The code structure and guidelines are light because this exercise is designed to test your critical thinking skills and see how you apply the skills youve learned throughout the duration of this class.

Use the following guidelines to complete this application:

Classes

Classes should be used to represent

Inventory Items

Customers

List(s)

Lists should be used to represent

The stores inventory

Customers shopping carts

Dictionary

A Dictionary should be used to

Track all of the customers - identified by their name

User Options

The user should have the following options

Select current shopper - list of all shoppers and option to create another shopper

View store inventory - list everything the store is selling

View cart - list of everything in the current Customers cart

Add item to cart - allow the user to select an item to add to the current Customers cart and remove it from the stores inventory. (Can be combined with the View store option if you wish)

Remove item from cart - allow the user to select an item to add to the stores inventory and remove it from the current Customers cart. (can be combined with the View cart option if you wish)

Complete purchase - Total up the cost of all of the items in the users cart and display that value. Remove the customer from the dictionary of customers

Exit - Exit the program

Logging

A logging class is used to log the required info to file log.txt

It is your choice on which method to log with. (log, logW, logD)

Required info

Current Customers name every time it changes

Item name and location (cart/store inventory) every time it changes

Customer name and purchase total when a purchase is completed

Input

All input should be validated and limited to the options presented to the user

The user should not be able to crash the program

Program should continue to run until the user chooses to exit

Extra Information

Go back through your code and check for the following:

All variables and methods are named appropriately.

Any information being output to the user should be clear and concise.

The user should be clearly informed of what is occurring throughout the application. When values change or objects are instantiated information about this occurrence should be displayed.

Make sure nothing accesses an object that doesnt exist.

******CEO4 instructions for reference since it is mentioned above******

For this activity you will be creating a basic logging framework which is a helpful item to have when developing and debugging larger applications. The framework will be set up using an interface and an abstract base class with two child logging classes: DoNotLog and LogToConsole. The rest of the program will consist of a car class and a menu in main with functionality that will allow the user to enable logging, disable logging, create a car, drive the car, Destroy the car, and exit the program.

Classes

Create an interface called ILog

The ILog interface must contain the following methods

Log - returns nothing and takes a string parameter

LogD - returns nothing and takes a string parameter

LogW - returns nothing and takes a string parameter

Create an abstract class called Logger that implements ILog

logger needs a protected static int field called lineNumber

this field will track the number of lines logged which will be used when data is logged.

Logger does not have to provide a body for the ILog methods it should declare them as abstract so that its children have to implement them.

Create a class called DoNotLog that inherits from Logger

Create a class called LogToConsole that inherits from Logger

Create a class called Car

Car should have the following fields

make of type string

model of type string

color of type string

mileage of type float

year of type int

Log Implementation

DoNotLog

Log - should do nothing

LogD - should do nothing

LogW - should do nothing

LogToConsole

Log - should use Console.Writeline to output the lineNumber and the string that was passed in. It should also increase the lineNumber.

LogD - should use Console.Writeline to output the lineNumber, the word DEBUG, and the string that was passed in. It should also increase the lineNumber.

LogW - should use Console.Writeline to output the lineNumber, the word WARNING, and the string that was passed in. It should also increase the lineNumber.

Program class

Before Main, create a private static field of type Logger

this field should be initialized to null

Needs a public static method GetLogger that returns the value held by the above field

Car Implementation

Needs a constructor that takes in parameters for each of its fields and initializes them

The new values of the cars fields should be logged using the LogD method of the static Logger object in the Program class. Use GetLogger().

Needs a Drive method that returns nothing and takes a parameter of type float

The value passed in should be used to update the cars mileage.

The new mileage should be logged using the LogW method of the static Logger object in the Program class. Use GetLogger().

Input Validation

Must be validated - prevent bad input from crashing the program.

Must be case insensitive - typing Exit, exit, and EXiT should all work.

Program must not crash if the user selects an option out of the expected order

ex. selecting drive car before one is created.

Main

In main before anything else you will need a Car variable to use for the currentCar.

Program runs until the user chooses to exit.

Menu

The menu must have the following options:

Disable logging - create a new DoNotLog object and store it in Programs static Logger field.

Enable logging - create a new LogToConsole object and store it in Programs static Logger field.

Create a car - prompt the user for values to create a car object and store the object in currentCar.

Drive the car - prompt the user for how far they are driving the car and call the Drive method on currentCar.

Destroy the car - set currentCar to null.

Exit - stop the program

Menu must handle numeric selection 1, 2, 3, etc as well as typed out options like disable logging.

Extra Information

Go back through your code and check for the following:

All variables and methods are named appropriately.

Any information being output to the user should be clear and concise.

The user should be clearly informed of what is occurring throughout the application. When values change or objects are instantiated information about this occurrence should be displayed.

Make sure nothing accesses an object that doesnt exist.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

One aspect of critical reasoning is being calm under pressure.

Answered: 1 week ago