This is my C# Visual studio code, its on 4 seperate pages, form1: public partial class Form1
Question:
This is my C# Visual studio code, its on 4 seperate pages, form1:
public partial class Form1 : Form
{
Car car = new Car();
public Form1()
{
InitializeComponent();
}
private void btnShow_Click(object sender, EventArgs e)
{
Car car = new Car();
car.Make = "Challenger";
car.Model = "Dodge";
car.Year = 2019;
car.MilesPerGallon = 38;
car.HorsePower = 300;
car.CarPrice = 29000;
car.Quantity = 1;
carTextBox.Text += "Car make is " + car.Make + ""
+ "Car Model is: " + car.Model + ""
+ "Car Year is: " + car.Year + ""
+ "Car Miles Per Gallon is: " + car.MilesPerGallon + ""
+ "Car Horse Power is: " + car.HorsePower + ""
+ "Quantity of cars in stock is: " + car.Quantity;
}
private void hideBtn_Click(object sender, EventArgs e)
{
carTextBox.Text = String.Empty;
}
public void btnAdd_Click(object sender, EventArgs e)
{
Car car = new Car();
}
private void removeItemButton_Click(object sender, EventArgs e)
{
}
private void restockItemButton_Click(object sender, EventArgs e)
{
}
private void searchPriceButton_Click(object sender, EventArgs e)
{
}
private void searchModelButton_Click(object sender, EventArgs e)
{
}
}
}
INVENTORY MANAGER:
internal class InventoryManager
{
private Car[] inventory;
public InventoryManager(int size)
{
inventory = new Car[size];
}
public void AddItem(Car item)
{
for (int i = 0; i < inventory.Length; i++)
{
if (inventory[i] == null)
{
inventory[i] = item;
break;
}
}
}
public void RemoveItem(Car item)
{
for (int i = 0; i < inventory.Length; i++)
{
if (inventory[i] == item)
{
inventory[i] = null;
break;
}
}
}
public void RestockItem(Car item, int quantity)
{
for (int i = 0; i < inventory.Length; i++)
{
if (inventory[i] == item)
{
inventory[i].Quantity += quantity;
break;
}
}
}
public void DisplayItems()
{
foreach (Car item in inventory)
{
if (item != null)
{
Console.WriteLine("Make: " + item.Make + ", Model: " + item.Model + ", Year: " + item.Year + ", MilesPerGallon: " + item.MilesPerGallon + ", HorsePower: " + item.HorsePower);
}
}
}
public Car[] SearchItemByName(string name)
{
List
foreach (Car item in inventory)
{
if (item != null && item.Make.ToLower().Contains(name.ToLower()))
{
result.Add(item);
}
}
return result.ToArray();
}
public Car[] SearchItemByPrice(int CarPrice)
{
List
foreach (Car item in inventory)
{
if (item != null && item.CarPrice == CarPrice)
{
result.Add(item);
}
}
return result.ToArray();
}
}
}
CAR CLASS:
internal class Car
{
public string Make { get; set; }
public string Model { get; set; }
public int Year { get; set; }
public int MilesPerGallon { get; set; }
public int HorsePower { get; set; }
public double CarPrice { get; set; }
public int Quantity { get; internal set; }
}
}
DRIVER PROGRAM TO TESTINVENTORY MANAGER:
internal class Driver
{
static void Main(string[] args)
{
// Create an inventory manager with a capacity of 10 items
InventoryManager manager = new InventoryManager(10);
// Add some cars to the inventory
manager.AddItem(new Car()
{
Make = "Ford",
Model = "Mustang",
Year = 2020,
MilesPerGallon = 22,
HorsePower = 450,
CarPrice = 35000,
Quantity = 5
});
manager.AddItem(new Car()
{
Make = "Chevrolet",
Model = "Camaro",
Year = 2019,
MilesPerGallon = 20,
HorsePower = 455,
CarPrice = 32000,
Quantity = 3
});
manager.AddItem(new Car()
{
Make = "Dodge",
Model = "Charger",
Year = 2018,
MilesPerGallon = 19,
HorsePower = 292,
CarPrice = 28000,
Quantity = 2
});
// Display all the cars in the inventory
manager.DisplayItems();
// Remove the Dodge Charger from the inventory
Car dodgeCharger = new Car()
{
Make = "Dodge",
Model = "Charger",
Year = 2018,
MilesPerGallon = 19,
HorsePower = 292,
CarPrice = 28000,
Quantity = 2
};
manager.RemoveItem(dodgeCharger);
// Display all the cars in the inventory again
manager.DisplayItems();
// Restock the Ford Mustang by 2 units
Car fordMustang = new Car()
{
Make = "Ford",
Model = "Mustang",
Year = 2020,
MilesPerGallon = 22,
HorsePower = 450,
CarPrice = 35000,
Quantity = 5
};
manager.RestockItem(fordMustang, 2);
// Display all the cars in the inventory again
manager.DisplayItems();
// Search for cars by name
Car[] searchResults = manager.SearchItemByName("Mustang");
foreach (Car car in searchResults)
{
Console.WriteLine("Make: " + car.Make + ", Model: " + car.Model);
}
// Search for cars by price
searchResults = manager.SearchItemByPrice(35000);
foreach (Car car in searchResults)
{
Console.WriteLine("Make: " + car.Make + ", Model: " + car.Model + ", Price: " + car.CarPrice);
}
Console.ReadLine();
}
}
}
This is what code needs: application should allow you to manipulate the inventory in your inventory manager through the user interface. should do the following:
Add a new item to the inventory manager.
Remove an item from the inventory.
Restock an item in the inventory.
Display the items in the inventory.
Search for an item/items in the inventory by a variety of criteria.
Update your inventory manager so that it uses a list to store inventory items instead of an array.
please build the whole application yourself in visual studio, and get a successful output and screenshot it please.
Introduction To Health Care Management
ISBN: 9781284081015
3rd Edition
Authors: Sharon B. Buchbinder, Nancy H. Shanks