SlideShare a Scribd company logo
1 of 6
Download to read offline
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);
// 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();
}
}
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<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);
}
}
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; }
}

More Related Content

Similar to I need to do the followingAdd a new item to the inventory m.pdf

Angular 2.0 Dependency injection
Angular 2.0 Dependency injectionAngular 2.0 Dependency injection
Angular 2.0 Dependency injectionEyal Vardi
 
Angular2: Quick overview with 2do app example
Angular2: Quick overview with 2do app exampleAngular2: Quick overview with 2do app example
Angular2: Quick overview with 2do app exampleAlexey Frolov
 
Google App Engine in 40 minutes (the absolute essentials)
Google App Engine in 40 minutes (the absolute essentials)Google App Engine in 40 minutes (the absolute essentials)
Google App Engine in 40 minutes (the absolute essentials)Python Ireland
 
Assignment DIn Problem D1 we will use a file to contain the dat.pdf
Assignment DIn Problem D1 we will use a file to contain the dat.pdfAssignment DIn Problem D1 we will use a file to contain the dat.pdf
Assignment DIn Problem D1 we will use a file to contain the dat.pdffasttrackscardecors
 
publicclass VehicleParser {publicstatic Vehicle parseStringToVehic.pdf
publicclass VehicleParser {publicstatic Vehicle parseStringToVehic.pdfpublicclass VehicleParser {publicstatic Vehicle parseStringToVehic.pdf
publicclass VehicleParser {publicstatic Vehicle parseStringToVehic.pdfANGELMARKETINGJAIPUR
 
Classes and Objects In C# With Example
Classes and Objects In C# With ExampleClasses and Objects In C# With Example
Classes and Objects In C# With ExampleCheezy Code
 
C#i need help creating the instance of stream reader to read from .pdf
C#i need help creating the instance of stream reader to read from .pdfC#i need help creating the instance of stream reader to read from .pdf
C#i need help creating the instance of stream reader to read from .pdfajantha11
 
Predicting model for prices of used cars
Predicting model for prices of used carsPredicting model for prices of used cars
Predicting model for prices of used carsHARPREETSINGH1862
 
Jan 2017 - a web of applications (angular 2)
Jan 2017 - a web of applications (angular 2)Jan 2017 - a web of applications (angular 2)
Jan 2017 - a web of applications (angular 2)Kasper Reijnders
 
#includeiostream #includecmath #includestringusing na.pdf
 #includeiostream #includecmath #includestringusing na.pdf #includeiostream #includecmath #includestringusing na.pdf
#includeiostream #includecmath #includestringusing na.pdfanuradhaartjwellery
 
#include iostream#include string#include iomanip#inclu.docx
#include iostream#include string#include iomanip#inclu.docx#include iostream#include string#include iomanip#inclu.docx
#include iostream#include string#include iomanip#inclu.docxmayank272369
 
How React Native, Appium and me made each other shine @Frontmania 16-11-2018
How React Native, Appium and me made each other shine @Frontmania 16-11-2018How React Native, Appium and me made each other shine @Frontmania 16-11-2018
How React Native, Appium and me made each other shine @Frontmania 16-11-2018Wim Selles
 
Scala Self Types by Gregor Heine, Principal Software Engineer at Gilt
Scala Self Types by Gregor Heine, Principal Software Engineer at GiltScala Self Types by Gregor Heine, Principal Software Engineer at Gilt
Scala Self Types by Gregor Heine, Principal Software Engineer at GiltGilt Tech Talks
 
Driverimport java.util.Scanner;A class that keeps a f.pdf
Driverimport java.util.Scanner;A class that keeps a f.pdfDriverimport java.util.Scanner;A class that keeps a f.pdf
Driverimport java.util.Scanner;A class that keeps a f.pdfarihantstoneart
 
srcCommissionCalculation.javasrcCommissionCalculation.javaimpo.docx
srcCommissionCalculation.javasrcCommissionCalculation.javaimpo.docxsrcCommissionCalculation.javasrcCommissionCalculation.javaimpo.docx
srcCommissionCalculation.javasrcCommissionCalculation.javaimpo.docxrafbolet0
 
#include iostream #include string #include fstream std.docx
#include iostream #include string #include fstream  std.docx#include iostream #include string #include fstream  std.docx
#include iostream #include string #include fstream std.docxajoy21
 
I have the first program completed (not how request, but it works) a.pdf
I have the first program completed (not how request, but it works) a.pdfI have the first program completed (not how request, but it works) a.pdf
I have the first program completed (not how request, but it works) a.pdffootworld1
 
angular fundamentals.pdf angular fundamentals.pdf
angular fundamentals.pdf angular fundamentals.pdfangular fundamentals.pdf angular fundamentals.pdf
angular fundamentals.pdf angular fundamentals.pdfNuttavutThongjor1
 

Similar to I need to do the followingAdd a new item to the inventory m.pdf (20)

Angular 2.0 Dependency injection
Angular 2.0 Dependency injectionAngular 2.0 Dependency injection
Angular 2.0 Dependency injection
 
Angular2: Quick overview with 2do app example
Angular2: Quick overview with 2do app exampleAngular2: Quick overview with 2do app example
Angular2: Quick overview with 2do app example
 
Google App Engine in 40 minutes (the absolute essentials)
Google App Engine in 40 minutes (the absolute essentials)Google App Engine in 40 minutes (the absolute essentials)
Google App Engine in 40 minutes (the absolute essentials)
 
Assignment DIn Problem D1 we will use a file to contain the dat.pdf
Assignment DIn Problem D1 we will use a file to contain the dat.pdfAssignment DIn Problem D1 we will use a file to contain the dat.pdf
Assignment DIn Problem D1 we will use a file to contain the dat.pdf
 
publicclass VehicleParser {publicstatic Vehicle parseStringToVehic.pdf
publicclass VehicleParser {publicstatic Vehicle parseStringToVehic.pdfpublicclass VehicleParser {publicstatic Vehicle parseStringToVehic.pdf
publicclass VehicleParser {publicstatic Vehicle parseStringToVehic.pdf
 
Classes and Objects In C# With Example
Classes and Objects In C# With ExampleClasses and Objects In C# With Example
Classes and Objects In C# With Example
 
C#i need help creating the instance of stream reader to read from .pdf
C#i need help creating the instance of stream reader to read from .pdfC#i need help creating the instance of stream reader to read from .pdf
C#i need help creating the instance of stream reader to read from .pdf
 
Predicting model for prices of used cars
Predicting model for prices of used carsPredicting model for prices of used cars
Predicting model for prices of used cars
 
Jan 2017 - a web of applications (angular 2)
Jan 2017 - a web of applications (angular 2)Jan 2017 - a web of applications (angular 2)
Jan 2017 - a web of applications (angular 2)
 
#includeiostream #includecmath #includestringusing na.pdf
 #includeiostream #includecmath #includestringusing na.pdf #includeiostream #includecmath #includestringusing na.pdf
#includeiostream #includecmath #includestringusing na.pdf
 
#include iostream#include string#include iomanip#inclu.docx
#include iostream#include string#include iomanip#inclu.docx#include iostream#include string#include iomanip#inclu.docx
#include iostream#include string#include iomanip#inclu.docx
 
How React Native, Appium and me made each other shine @Frontmania 16-11-2018
How React Native, Appium and me made each other shine @Frontmania 16-11-2018How React Native, Appium and me made each other shine @Frontmania 16-11-2018
How React Native, Appium and me made each other shine @Frontmania 16-11-2018
 
Scala Self Types by Gregor Heine, Principal Software Engineer at Gilt
Scala Self Types by Gregor Heine, Principal Software Engineer at GiltScala Self Types by Gregor Heine, Principal Software Engineer at Gilt
Scala Self Types by Gregor Heine, Principal Software Engineer at Gilt
 
Driverimport java.util.Scanner;A class that keeps a f.pdf
Driverimport java.util.Scanner;A class that keeps a f.pdfDriverimport java.util.Scanner;A class that keeps a f.pdf
Driverimport java.util.Scanner;A class that keeps a f.pdf
 
srcCommissionCalculation.javasrcCommissionCalculation.javaimpo.docx
srcCommissionCalculation.javasrcCommissionCalculation.javaimpo.docxsrcCommissionCalculation.javasrcCommissionCalculation.javaimpo.docx
srcCommissionCalculation.javasrcCommissionCalculation.javaimpo.docx
 
#include iostream #include string #include fstream std.docx
#include iostream #include string #include fstream  std.docx#include iostream #include string #include fstream  std.docx
#include iostream #include string #include fstream std.docx
 
29. Treffen - Tobias Meier - TypeScript
29. Treffen - Tobias Meier - TypeScript29. Treffen - Tobias Meier - TypeScript
29. Treffen - Tobias Meier - TypeScript
 
I have the first program completed (not how request, but it works) a.pdf
I have the first program completed (not how request, but it works) a.pdfI have the first program completed (not how request, but it works) a.pdf
I have the first program completed (not how request, but it works) a.pdf
 
angular fundamentals.pdf angular fundamentals.pdf
angular fundamentals.pdf angular fundamentals.pdfangular fundamentals.pdf angular fundamentals.pdf
angular fundamentals.pdf angular fundamentals.pdf
 
Itsjustangular
ItsjustangularItsjustangular
Itsjustangular
 

More from adianantsolutions

Nancy acaba de vender algunas de sus acciones en Spotify Inc.pdf
Nancy acaba de vender algunas de sus acciones en Spotify Inc.pdfNancy acaba de vender algunas de sus acciones en Spotify Inc.pdf
Nancy acaba de vender algunas de sus acciones en Spotify Inc.pdfadianantsolutions
 
Name this accessory gland to the digestive systemName th.pdf
Name this accessory gland to the digestive systemName th.pdfName this accessory gland to the digestive systemName th.pdf
Name this accessory gland to the digestive systemName th.pdfadianantsolutions
 
Name of Bacteria Observation Results E coli Yellow s.pdf
Name of Bacteria    Observation    Results  E coli Yellow s.pdfName of Bacteria    Observation    Results  E coli Yellow s.pdf
Name of Bacteria Observation Results E coli Yellow s.pdfadianantsolutions
 
Nasopharyngeal aspirates samples are used to investigate the.pdf
Nasopharyngeal aspirates samples are used to investigate the.pdfNasopharyngeal aspirates samples are used to investigate the.pdf
Nasopharyngeal aspirates samples are used to investigate the.pdfadianantsolutions
 
Mutating His E7 the distal His in myoglobin to a Gly would.pdf
Mutating His E7 the distal His in myoglobin to a Gly would.pdfMutating His E7 the distal His in myoglobin to a Gly would.pdf
Mutating His E7 the distal His in myoglobin to a Gly would.pdfadianantsolutions
 
Muthata1Calleingove LatinatLahr Nereant 1 17ar.pdf
Muthata1Calleingove LatinatLahr Nereant 1 17ar.pdfMuthata1Calleingove LatinatLahr Nereant 1 17ar.pdf
Muthata1Calleingove LatinatLahr Nereant 1 17ar.pdfadianantsolutions
 
Nadine LeMieux has just inherited 8000 She wants to use t.pdf
Nadine LeMieux has just inherited 8000 She wants to use t.pdfNadine LeMieux has just inherited 8000 She wants to use t.pdf
Nadine LeMieux has just inherited 8000 She wants to use t.pdfadianantsolutions
 
NAD Participa en la hidrlisis de la sacarosa a glucosa e.pdf
NAD  Participa en la hidrlisis de la sacarosa a glucosa  e.pdfNAD  Participa en la hidrlisis de la sacarosa a glucosa  e.pdf
NAD Participa en la hidrlisis de la sacarosa a glucosa e.pdfadianantsolutions
 
Multi choice Which sequence represents the correct sequence .pdf
Multi choice Which sequence represents the correct sequence .pdfMulti choice Which sequence represents the correct sequence .pdf
Multi choice Which sequence represents the correct sequence .pdfadianantsolutions
 
n2 1 let xPn Show that yv2x0X22n 2 Let x1x2.pdf
n2  1 let xPn Show that yv2x0X22n 2 Let x1x2.pdfn2  1 let xPn Show that yv2x0X22n 2 Let x1x2.pdf
n2 1 let xPn Show that yv2x0X22n 2 Let x1x2.pdfadianantsolutions
 
n Faturalama Belgesi ilevini kullanmak iin n koullar nele.pdf
n Faturalama Belgesi ilevini kullanmak iin n koullar nele.pdfn Faturalama Belgesi ilevini kullanmak iin n koullar nele.pdf
n Faturalama Belgesi ilevini kullanmak iin n koullar nele.pdfadianantsolutions
 
Myra had high scores as cooperative team player evenkeele.pdf
Myra had high scores as cooperative team player evenkeele.pdfMyra had high scores as cooperative team player evenkeele.pdf
Myra had high scores as cooperative team player evenkeele.pdfadianantsolutions
 
Mycobacterium tuberculosis infecta a casi 13 de la poblaci.pdf
Mycobacterium tuberculosis infecta a casi 13 de la poblaci.pdfMycobacterium tuberculosis infecta a casi 13 de la poblaci.pdf
Mycobacterium tuberculosis infecta a casi 13 de la poblaci.pdfadianantsolutions
 
My library gt IT 145 Intro to Software Development home .pdf
My library gt IT 145 Intro to Software Development home .pdfMy library gt IT 145 Intro to Software Development home .pdf
My library gt IT 145 Intro to Software Development home .pdfadianantsolutions
 
My code is below How do I write this code without usin.pdf
My code is below How do I write this code without usin.pdfMy code is below How do I write this code without usin.pdf
My code is below How do I write this code without usin.pdfadianantsolutions
 
My essay topic is Water Pollution in black Mississippi Jacks.pdf
My essay topic is Water Pollution in black Mississippi Jacks.pdfMy essay topic is Water Pollution in black Mississippi Jacks.pdf
My essay topic is Water Pollution in black Mississippi Jacks.pdfadianantsolutions
 
Msrda renkli bir aleuron tohumun bir ksm bir maddenin var.pdf
Msrda renkli bir aleuron tohumun bir ksm bir maddenin var.pdfMsrda renkli bir aleuron tohumun bir ksm bir maddenin var.pdf
Msrda renkli bir aleuron tohumun bir ksm bir maddenin var.pdfadianantsolutions
 
MRPnin baarl bir ekilde uygulanmas ve iletilmesi iin aadak.pdf
MRPnin baarl bir ekilde uygulanmas ve iletilmesi iin aadak.pdfMRPnin baarl bir ekilde uygulanmas ve iletilmesi iin aadak.pdf
MRPnin baarl bir ekilde uygulanmas ve iletilmesi iin aadak.pdfadianantsolutions
 
Mr senabe is a senior teacher in a secondary school he has.pdf
Mr senabe is a senior teacher in a secondary school he has.pdfMr senabe is a senior teacher in a secondary school he has.pdf
Mr senabe is a senior teacher in a secondary school he has.pdfadianantsolutions
 
Multiple Choice that those genes are not useful in interpret.pdf
Multiple Choice that those genes are not useful in interpret.pdfMultiple Choice that those genes are not useful in interpret.pdf
Multiple Choice that those genes are not useful in interpret.pdfadianantsolutions
 

More from adianantsolutions (20)

Nancy acaba de vender algunas de sus acciones en Spotify Inc.pdf
Nancy acaba de vender algunas de sus acciones en Spotify Inc.pdfNancy acaba de vender algunas de sus acciones en Spotify Inc.pdf
Nancy acaba de vender algunas de sus acciones en Spotify Inc.pdf
 
Name this accessory gland to the digestive systemName th.pdf
Name this accessory gland to the digestive systemName th.pdfName this accessory gland to the digestive systemName th.pdf
Name this accessory gland to the digestive systemName th.pdf
 
Name of Bacteria Observation Results E coli Yellow s.pdf
Name of Bacteria    Observation    Results  E coli Yellow s.pdfName of Bacteria    Observation    Results  E coli Yellow s.pdf
Name of Bacteria Observation Results E coli Yellow s.pdf
 
Nasopharyngeal aspirates samples are used to investigate the.pdf
Nasopharyngeal aspirates samples are used to investigate the.pdfNasopharyngeal aspirates samples are used to investigate the.pdf
Nasopharyngeal aspirates samples are used to investigate the.pdf
 
Mutating His E7 the distal His in myoglobin to a Gly would.pdf
Mutating His E7 the distal His in myoglobin to a Gly would.pdfMutating His E7 the distal His in myoglobin to a Gly would.pdf
Mutating His E7 the distal His in myoglobin to a Gly would.pdf
 
Muthata1Calleingove LatinatLahr Nereant 1 17ar.pdf
Muthata1Calleingove LatinatLahr Nereant 1 17ar.pdfMuthata1Calleingove LatinatLahr Nereant 1 17ar.pdf
Muthata1Calleingove LatinatLahr Nereant 1 17ar.pdf
 
Nadine LeMieux has just inherited 8000 She wants to use t.pdf
Nadine LeMieux has just inherited 8000 She wants to use t.pdfNadine LeMieux has just inherited 8000 She wants to use t.pdf
Nadine LeMieux has just inherited 8000 She wants to use t.pdf
 
NAD Participa en la hidrlisis de la sacarosa a glucosa e.pdf
NAD  Participa en la hidrlisis de la sacarosa a glucosa  e.pdfNAD  Participa en la hidrlisis de la sacarosa a glucosa  e.pdf
NAD Participa en la hidrlisis de la sacarosa a glucosa e.pdf
 
Multi choice Which sequence represents the correct sequence .pdf
Multi choice Which sequence represents the correct sequence .pdfMulti choice Which sequence represents the correct sequence .pdf
Multi choice Which sequence represents the correct sequence .pdf
 
n2 1 let xPn Show that yv2x0X22n 2 Let x1x2.pdf
n2  1 let xPn Show that yv2x0X22n 2 Let x1x2.pdfn2  1 let xPn Show that yv2x0X22n 2 Let x1x2.pdf
n2 1 let xPn Show that yv2x0X22n 2 Let x1x2.pdf
 
n Faturalama Belgesi ilevini kullanmak iin n koullar nele.pdf
n Faturalama Belgesi ilevini kullanmak iin n koullar nele.pdfn Faturalama Belgesi ilevini kullanmak iin n koullar nele.pdf
n Faturalama Belgesi ilevini kullanmak iin n koullar nele.pdf
 
Myra had high scores as cooperative team player evenkeele.pdf
Myra had high scores as cooperative team player evenkeele.pdfMyra had high scores as cooperative team player evenkeele.pdf
Myra had high scores as cooperative team player evenkeele.pdf
 
Mycobacterium tuberculosis infecta a casi 13 de la poblaci.pdf
Mycobacterium tuberculosis infecta a casi 13 de la poblaci.pdfMycobacterium tuberculosis infecta a casi 13 de la poblaci.pdf
Mycobacterium tuberculosis infecta a casi 13 de la poblaci.pdf
 
My library gt IT 145 Intro to Software Development home .pdf
My library gt IT 145 Intro to Software Development home .pdfMy library gt IT 145 Intro to Software Development home .pdf
My library gt IT 145 Intro to Software Development home .pdf
 
My code is below How do I write this code without usin.pdf
My code is below How do I write this code without usin.pdfMy code is below How do I write this code without usin.pdf
My code is below How do I write this code without usin.pdf
 
My essay topic is Water Pollution in black Mississippi Jacks.pdf
My essay topic is Water Pollution in black Mississippi Jacks.pdfMy essay topic is Water Pollution in black Mississippi Jacks.pdf
My essay topic is Water Pollution in black Mississippi Jacks.pdf
 
Msrda renkli bir aleuron tohumun bir ksm bir maddenin var.pdf
Msrda renkli bir aleuron tohumun bir ksm bir maddenin var.pdfMsrda renkli bir aleuron tohumun bir ksm bir maddenin var.pdf
Msrda renkli bir aleuron tohumun bir ksm bir maddenin var.pdf
 
MRPnin baarl bir ekilde uygulanmas ve iletilmesi iin aadak.pdf
MRPnin baarl bir ekilde uygulanmas ve iletilmesi iin aadak.pdfMRPnin baarl bir ekilde uygulanmas ve iletilmesi iin aadak.pdf
MRPnin baarl bir ekilde uygulanmas ve iletilmesi iin aadak.pdf
 
Mr senabe is a senior teacher in a secondary school he has.pdf
Mr senabe is a senior teacher in a secondary school he has.pdfMr senabe is a senior teacher in a secondary school he has.pdf
Mr senabe is a senior teacher in a secondary school he has.pdf
 
Multiple Choice that those genes are not useful in interpret.pdf
Multiple Choice that those genes are not useful in interpret.pdfMultiple Choice that those genes are not useful in interpret.pdf
Multiple Choice that those genes are not useful in interpret.pdf
 

Recently uploaded

Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 

Recently uploaded (20)

Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
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; } }