I need to 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. I believe my driver program does this with the
inventory manager, but now I need this to do it on the form application. I also need to Update the
inventory manager so that it uses a list to store inventory items instead of an array. Here are my
four pages of code in c# Visual studio: public partial class Form1:
{
Car car = new Car();
InventoryManager manager = new InventoryManager(10);
public Form1()
{
InitializeComponent();
}
private void btnShow_Click(object sender, EventArgs e)
{
Car car = new Car();
// Display all the cars in the inventory
manager.DisplayItems();
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 + "rn"
+ "Car Model is: " + car.Model + "rn"
+ "Car Year is: " + car.Year + "rn"
+ "Car Miles Per Gallon is: " + car.MilesPerGallon + "rn"
+ "Car Horse Power is: " + car.HorsePower + "rn"
+ "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)
{
// Display all the cars in the inventory
manager.DisplayItems();
}
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)
{
}
}
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);
// D.
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
I need to do the followingAdd a new item to the inventory m.pdf
1. I need to 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. I believe my driver program does this with the
inventory manager, but now I need this to do it on the form application. I also need to Update the
inventory manager so that it uses a list to store inventory items instead of an array. Here are my
four pages of code in c# Visual studio: public partial class Form1:
{
Car car = new Car();
InventoryManager manager = new InventoryManager(10);
public Form1()
{
InitializeComponent();
}
private void btnShow_Click(object sender, EventArgs e)
{
Car car = new Car();
// Display all the cars in the inventory
manager.DisplayItems();
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 + "rn"
+ "Car Model is: " + car.Model + "rn"
+ "Car Year is: " + car.Year + "rn"
+ "Car Miles Per Gallon is: " + car.MilesPerGallon + "rn"
+ "Car Horse Power is: " + car.HorsePower + "rn"
+ "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)
{
// Display all the cars in the inventory
manager.DisplayItems();
}
2. 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)
{
}
}
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()
{
3. 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)
{
4. 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();
}
}
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)
{
5. 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<Car> result = new List<Car>();
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<Car> result = new List<Car>();
foreach (Car item in inventory)
{
if (item != null && item.CarPrice == CarPrice)
{
result.Add(item);
}
}
6. return result.ToArray();
}
}
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; }
}