Note: This is in C# using visual basic. MyNovant Garland Tools DatebBitcon Excha
ID: 3920275 • Letter: N
Question
Note: This is in C# using visual basic. MyNovant Garland Tools DatebBitcon Exchange AT&T; Security Serve The Fresh Prince of Inventory Management System Objective Work with multiple objects and reading data files. ?? Description: A wholesale distributor has six warehouses (Atlanta, Baltimore, Chicago, Denver, Ely and Fargo) and sells five different iterms (identified by part number: 102, 215, 410, 525 and 711). Each warehouse may stock any or all of the five items. The company buys and sells these items constantly. Company transaction records contain a transaction code (P for a purchase or 'S' for a sale) followed by an item numbe and the quantity (bought or sold). The transaction records are contained in a transaction data file named Transactions.bxt. Sample transaction records: P 410 1000 S 215 120 S 711 300 Transactions.txt A separate data file contains the initial status of the six warehouses at the beginning of the day (i.e., the ending status from the night before). This data file has only six records (lines). Each record (line) contains five numbers that show the quantity on hand for the five items in that warehouse. This file is named Inventory.txt Sample status data file: Inventory.txt 500 120 60 0 350 100 230 0 500 075 00220 600 50 120 300 40 210 160 30 80 50 90 50 90 200 70 The status data file is updated by processing the transaction records in the transaction data file according to these rules: 1- For a sale (S')-subtract the quantity sold from the warehouse that has the largest supply of that item on hand 2- For a purchase (P)-add the quantity purchased to the warehouse that has the lowest supply of that item on hand. Instructions: Write an object-oriented C# application to do the above inventory warehouse processing. Each of the six warehouses should be treated as an individual object. For example, Allanta would be an object with each of the five part numbers as instance fields. Each of the other warehouses should also be objects with the five part numbers as instance fields. Of course, there would be one class which would be the main (driver) class from which these 6 objects would be created. In the beginning of the program, the status data file (Inventory.txt) should be read and an object for each warehouse created. The Inventory.txt data file is in the following order: the first line is the Allanta warehouse, the second line is the Baltimore warehouse, third Chicago, then Denver, Ely and Fargo. After the objects are created, the transactions data file (Transactions.txt) are read and processed The objects should be updated as the transaction records are read and processedExplanation / Answer
ScreenShot
-----------------------------------------------------
Program
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace InventoryApplication
{
/*Warehoueses are made of seperate classes
* Create their own member variables(parts),set and get functions
* display each parts details by overloading toString()
*/
class Atlanta
{
int partNumber102;
int partNumber215;
int partNumber410;
int partNumber525;
int partNumber711;
public void setPart102(int p1)
{
partNumber102 = p1;
}
public void setPart215(int p2)
{
partNumber215 = p2;
}
public void setPart410(int p3)
{
partNumber410 = p3;
}
public void setPart525(int p4)
{
partNumber525 = p4;
}
public void setPart711(int p5)
{
partNumber711 = p5;
}
public int getPart102()
{
return partNumber102;
}
public int getPart215()
{
return partNumber215;
}
public int getPart410()
{
return partNumber410;
}
public int getPart525()
{
return partNumber525;
}
public int getPart711()
{
return partNumber711;
}
public String toString()
{
return ("Part102= "+partNumber102 + ",Part215 = "+ partNumber215 + ",Part410 = " + " "+partNumber410 + ",Part525 = " + partNumber525 + ",Part711 = " + partNumber711);
}
}
/*Warehoueses are made of seperate classes
* Create their own member variables(parts),set and get functions
* display each parts details by overloading toString()
*/
class Chicago
{
int partNumber102;
int partNumber215;
int partNumber410;
int partNumber525;
int partNumber711;
public void setPart102(int p1)
{
partNumber102 = p1;
}
public void setPart215(int p2)
{
partNumber215 = p2;
}
public void setPart410(int p3)
{
partNumber410 = p3;
}
public void setPart525(int p4)
{
partNumber525 = p4;
}
public void setPart711(int p5)
{
partNumber711 = p5;
}
public int getPart102()
{
return partNumber102;
}
public int getPart215()
{
return partNumber215;
}
public int getPart410()
{
return partNumber410;
}
public int getPart525()
{
return partNumber525;
}
public int getPart711()
{
return partNumber711;
}
public String toString()
{
return ("Part102= " + partNumber102 + ",Part215 = " + partNumber215 + ",Part410 = " + " " + partNumber410 + ",Part525 = " + partNumber525 + ",Part711 = " + partNumber711);
}
}
/*Warehoueses are made of seperate classes
* Create their own member variables(parts),set and get functions
* display each parts details by overloading toString()
*/
class Baltimore
{
int partNumber102;
int partNumber215;
int partNumber410;
int partNumber525;
int partNumber711;
public void setPart102(int p1)
{
partNumber102 = p1;
}
public void setPart215(int p2)
{
partNumber215 = p2;
}
public void setPart410(int p3)
{
partNumber410 = p3;
}
public void setPart525(int p4)
{
partNumber525 = p4;
}
public void setPart711(int p5)
{
partNumber711 = p5;
}
public int getPart102()
{
return partNumber102;
}
public int getPart215()
{
return partNumber215;
}
public int getPart410()
{
return partNumber410;
}
public int getPart525()
{
return partNumber525;
}
public int getPart711()
{
return partNumber711;
}
public String toString()
{
return ("Part102= " + partNumber102 + ",Part215 = " + partNumber215 + ",Part410 = " + " " + partNumber410 + ",Part525 = " + partNumber525 + ",Part711 = " + partNumber711);
}
}
/*Warehoueses are made of seperate classes
* Create their own member variables(parts),set and get functions
* display each parts details by overloading toString()
*/
class Denver
{
int partNumber102;
int partNumber215;
int partNumber410;
int partNumber525;
int partNumber711;
public void setPart102(int p1)
{
partNumber102 = p1;
}
public void setPart215(int p2)
{
partNumber215 = p2;
}
public void setPart410(int p3)
{
partNumber410 = p3;
}
public void setPart525(int p4)
{
partNumber525 = p4;
}
public void setPart711(int p5)
{
partNumber711 = p5;
}
public int getPart102()
{
return partNumber102;
}
public int getPart215()
{
return partNumber215;
}
public int getPart410()
{
return partNumber410;
}
public int getPart525()
{
return partNumber525;
}
public int getPart711()
{
return partNumber711;
}
public String toString()
{
return ("Part102= " + partNumber102 + ",Part215 = " + partNumber215 + ",Part410 = " + " " + partNumber410 + ",Part525 = " + partNumber525 + ",Part711 = " + partNumber711);
}
}
/*Warehoueses are made of seperate classes
* Create their own member variables(parts),set and get functions
* display each parts details by overloading toString()
*/
class Ely
{
int partNumber102;
int partNumber215;
int partNumber410;
int partNumber525;
int partNumber711;
public void setPart102(int p1)
{
partNumber102 = p1;
}
public void setPart215(int p2)
{
partNumber215 = p2;
}
public void setPart410(int p3)
{
partNumber410 = p3;
}
public void setPart525(int p4)
{
partNumber525 = p4;
}
public void setPart711(int p5)
{
partNumber711 = p5;
}
public int getPart102()
{
return partNumber102;
}
public int getPart215()
{
return partNumber215;
}
public int getPart410()
{
return partNumber410;
}
public int getPart525()
{
return partNumber525;
}
public int getPart711()
{
return partNumber711;
}
public String toString()
{
return ("Part102= " + partNumber102 + ",Part215 = " + partNumber215 + ",Part410 = " + " " + partNumber410 + ",Part525 = " + partNumber525 + ",Part711 = " + partNumber711);
}
}
/*Warehoueses are made of seperate classes
* Create their own member variables(parts),set and get functions
* display each parts details by overloading toString()
*/
class Fargo
{
int partNumber102;
int partNumber215;
int partNumber410;
int partNumber525;
int partNumber711;
public void setPart102(int p1)
{
partNumber102 = p1;
}
public void setPart215(int p2)
{
partNumber215 = p2;
}
public void setPart410(int p3)
{
partNumber410 = p3;
}
public void setPart525(int p4)
{
partNumber525 = p4;
}
public void setPart711(int p5)
{
partNumber711 = p5;
}
public int getPart102()
{
return partNumber102;
}
public int getPart215()
{
return partNumber215;
}
public int getPart410()
{
return partNumber410;
}
public int getPart525()
{
return partNumber525;
}
public int getPart711()
{
return partNumber711;
}
public String toString()
{
return ("Part102= " + partNumber102 + ",Part215 = " + partNumber215 + ",Part410 = " + " " + partNumber410 + ",Part525 = " + partNumber525 + ",Part711 = " + partNumber711);
}
}
//Main class
class Program
{
static void Main(string[] args)
{
//Variable to identify line number of file read
var lineCount = 1;
//Each class object created
Atlanta at = new Atlanta();
Baltimore bt = new Baltimore();
Chicago ch = new Chicago();
Ely el = new Ely();
Denver dn = new Denver();
Fargo fr = new Fargo();
//Read Inventory file and store as each object values
var fileStream = new FileStream(@"c:/Users/deept/Desktop/Inventory.txt", FileMode.Open, FileAccess.Read);
using (var streamReader = new StreamReader(fileStream, Encoding.UTF8))
{
string line;
while ((line = streamReader.ReadLine()) != null)
{
if (lineCount == 1)
{
String[] arr = line.Split();
at.setPart102(Int32.Parse(arr[0]));
at.setPart215(Int32.Parse(arr[1]));
at.setPart410(Int32.Parse(arr[2]));
at.setPart525(Int32.Parse(arr[3]));
at.setPart711(Int32.Parse(arr[4]));
lineCount++;
}
else if (lineCount == 2)
{
String[] arr = line.Split();
bt.setPart102(Int32.Parse(arr[0]));
bt.setPart215(Int32.Parse(arr[1]));
bt.setPart410(Int32.Parse(arr[2]));
bt.setPart525(Int32.Parse(arr[3]));
bt.setPart711(Int32.Parse(arr[4]));
lineCount++;
}
else if (lineCount == 3)
{
String[] arr = line.Split();
ch.setPart102(Int32.Parse(arr[0]));
ch.setPart215(Int32.Parse(arr[1]));
ch.setPart410(Int32.Parse(arr[2]));
ch.setPart525(Int32.Parse(arr[3]));
ch.setPart711(Int32.Parse(arr[4]));
lineCount++;
}
else if (lineCount == 4)
{
String[] arr = line.Split();
dn.setPart102(Int32.Parse(arr[0]));
dn.setPart215(Int32.Parse(arr[1]));
dn.setPart410(Int32.Parse(arr[2]));
dn.setPart525(Int32.Parse(arr[3]));
dn.setPart711(Int32.Parse(arr[4]));
lineCount++;
}
else if (lineCount == 5)
{
String[] arr = line.Split();
el.setPart102(Int32.Parse(arr[0]));
el.setPart215(Int32.Parse(arr[1]));
el.setPart410(Int32.Parse(arr[2]));
el.setPart525(Int32.Parse(arr[3]));
el.setPart711(Int32.Parse(arr[4]));
lineCount++;
}
else if (lineCount == 6)
{
String[] arr = line.Split();
fr.setPart102(Int32.Parse(arr[0]));
fr.setPart215(Int32.Parse(arr[1]));
fr.setPart410(Int32.Parse(arr[2]));
fr.setPart525(Int32.Parse(arr[3]));
fr.setPart711(Int32.Parse(arr[4]));
lineCount++;
}
}
}
//Display details
Console.WriteLine("Before Transaction : ");
Console.WriteLine("Atlanta: {0}", at.toString());
Console.WriteLine("Baltimore: {0}", bt.toString());
Console.WriteLine("Chicago: {0}", ch.toString());
Console.WriteLine("Denver: {0}", dn.toString());
Console.WriteLine("Ely: {0}", el.toString());
Console.WriteLine("Fargo: {0}", fr.toString());
//Transaction file read
fileStream = new FileStream(@"c:/Users/deept/Desktop/Transactions.txt", FileMode.Open, FileAccess.Read);
using (var streamReader = new StreamReader(fileStream, Encoding.UTF8))
{
string line;
while ((line = streamReader.ReadLine()) != null)
{
String[] arr = line.Split();
if (arr[0] == "P")
{
if (arr[1] == "102")
{
at.setPart102(at.getPart102() + Int32.Parse(arr[2]));
bt.setPart102(bt.getPart102() + Int32.Parse(arr[2]));
ch.setPart102(ch.getPart102() + Int32.Parse(arr[2]));
dn.setPart102(dn.getPart102() + Int32.Parse(arr[2]));
el.setPart102(el.getPart102() + Int32.Parse(arr[2]));
fr.setPart102(fr.getPart102() + Int32.Parse(arr[2]));
}
else if (arr[1] == "215")
{
at.setPart215(at.getPart215() + Int32.Parse(arr[2]));
bt.setPart215(bt.getPart215() + Int32.Parse(arr[2]));
ch.setPart215(ch.getPart215() + Int32.Parse(arr[2]));
dn.setPart215(dn.getPart215() + Int32.Parse(arr[2]));
el.setPart215(el.getPart215() + Int32.Parse(arr[2]));
fr.setPart215(fr.getPart215() + Int32.Parse(arr[2]));
}
else if (arr[1]=="410")
{
at.setPart410(at.getPart410() + Int32.Parse(arr[2]));
bt.setPart410(bt.getPart410() + Int32.Parse(arr[2]));
ch.setPart410(ch.getPart410() + Int32.Parse(arr[2]));
dn.setPart410(dn.getPart410() + Int32.Parse(arr[2]));
el.setPart410(el.getPart410() + Int32.Parse(arr[2]));
fr.setPart410(fr.getPart410() + Int32.Parse(arr[2]));
}
else if (arr[1] == "525")
{
at.setPart525(at.getPart525() + Int32.Parse(arr[2]));
bt.setPart525(bt.getPart525() + Int32.Parse(arr[2]));
ch.setPart525(ch.getPart525() + Int32.Parse(arr[2]));
dn.setPart525(dn.getPart525() + Int32.Parse(arr[2]));
el.setPart525(el.getPart525() + Int32.Parse(arr[2]));
fr.setPart525(fr.getPart525() + Int32.Parse(arr[2]));
}
else if (arr[1] == "711")
{
at.setPart711(at.getPart711() + Int32.Parse(arr[2]));
bt.setPart711(bt.getPart711() + Int32.Parse(arr[2]));
ch.setPart711(ch.getPart711() + Int32.Parse(arr[2]));
dn.setPart711(dn.getPart711() + Int32.Parse(arr[2]));
el.setPart711(el.getPart711() + Int32.Parse(arr[2]));
fr.setPart711(fr.getPart711() + Int32.Parse(arr[2]));
}
}
else if (arr[0] == "S")
{
if (arr[1] == "102")
{
at.setPart102(at.getPart102() - Int32.Parse(arr[2]));
bt.setPart102(bt.getPart102() - Int32.Parse(arr[2]));
ch.setPart102(ch.getPart102() - Int32.Parse(arr[2]));
dn.setPart102(dn.getPart102() - Int32.Parse(arr[2]));
el.setPart102(el.getPart102() - Int32.Parse(arr[2]));
fr.setPart102(fr.getPart102() - Int32.Parse(arr[2]));
}
else if (arr[1] == "215")
{
at.setPart215(at.getPart215() - Int32.Parse(arr[2]));
bt.setPart215(bt.getPart215() - Int32.Parse(arr[2]));
ch.setPart215(ch.getPart215() - Int32.Parse(arr[2]));
dn.setPart215(dn.getPart215() - Int32.Parse(arr[2]));
el.setPart215(el.getPart215() - Int32.Parse(arr[2]));
fr.setPart215(fr.getPart215() - Int32.Parse(arr[2]));
}
else if (arr[1] == "410")
{
at.setPart410(at.getPart410() - Int32.Parse(arr[2]));
bt.setPart410(bt.getPart410() - Int32.Parse(arr[2]));
ch.setPart410(ch.getPart410() - Int32.Parse(arr[2]));
dn.setPart410(dn.getPart410() - Int32.Parse(arr[2]));
el.setPart410(el.getPart410() - Int32.Parse(arr[2]));
fr.setPart410(fr.getPart410() - Int32.Parse(arr[2]));
}
else if (arr[1] == "525")
{
at.setPart525(at.getPart525() - Int32.Parse(arr[2]));
bt.setPart525(bt.getPart525() - Int32.Parse(arr[2]));
ch.setPart525(ch.getPart525() - Int32.Parse(arr[2]));
dn.setPart525(dn.getPart525() - Int32.Parse(arr[2]));
el.setPart525(el.getPart525() - Int32.Parse(arr[2]));
fr.setPart525(fr.getPart525() - Int32.Parse(arr[2]));
}
else if (arr[1] == "711")
{
at.setPart711(at.getPart711() - Int32.Parse(arr[2]));
bt.setPart711(bt.getPart711() - Int32.Parse(arr[2]));
ch.setPart711(ch.getPart711() - Int32.Parse(arr[2]));
dn.setPart711(dn.getPart711() - Int32.Parse(arr[2]));
el.setPart711(el.getPart711() - Int32.Parse(arr[2]));
fr.setPart711(fr.getPart711() - Int32.Parse(arr[2]));
}
}
}
}
//Display result after processing
Console.WriteLine("After Transaction : ");
Console.WriteLine("Atlanta: {0}", at.toString());
Console.WriteLine("Baltimore: {0}", bt.toString());
Console.WriteLine("Chicago: {0}", ch.toString());
Console.WriteLine("Denver: {0}", dn.toString());
Console.WriteLine("Ely: {0}", el.toString());
Console.WriteLine("Fargo: {0}", fr.toString());
}
}
}
------------------------------------------------------
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.