0% found this document useful (0 votes)
37 views

Using System - Collections.Generic Using System - Collections.Objectmodel Namespace Project - 1

The document defines classes for representing product lines, stock, items, and receipts for a sales system. The Line class represents a product line with properties for the SKU, description, and associated stock. Stock is represented by abstract Stock and concrete DiscreteStock and WeighedStock classes. The Item class represents a purchased item with properties like quantity and weight. The Receipt class is meant to contain purchase information. Static methods are included on Line to retrieve lines by SKU and create new lines associated with discrete or weighed stock types.

Uploaded by

amrutha
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

Using System - Collections.Generic Using System - Collections.Objectmodel Namespace Project - 1

The document defines classes for representing product lines, stock, items, and receipts for a sales system. The Line class represents a product line with properties for the SKU, description, and associated stock. Stock is represented by abstract Stock and concrete DiscreteStock and WeighedStock classes. The Item class represents a purchased item with properties like quantity and weight. The Receipt class is meant to contain purchase information. Static methods are included on Line to retrieve lines by SKU and create new lines associated with discrete or weighed stock types.

Uploaded by

amrutha
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

using System.Collections.

Generic;
using System.Collections.ObjectModel;

namespace Project_1
{
class Line
{
private string _ProductSKU;
public string ProductSKU
{
get { return _ProductSKU; }
}

private string _Description;


public string Description
{
get { return _Description; }
}

private Stock _Stock;


public Stock Stock
{
get { return _Stock; }
}

private Line(string sku, string description)


{
_ProductSKU = sku;
_Description = description;
}

private static List<Line> _SaleLines = new List<Line>();


public static ReadOnlyCollection<Line> SaleLines
{
get { return _SaleLines.AsReadOnly(); }
}

public static Line SKU(string sku)


{
Line result = null;
foreach (Line l in _SaleLines)
{
if (l.ProductSKU == sku)
{
result = l;
break;
}
}
return result;
}

public static bool CreateDiscreteLine(string sku, string description,


double weightPerItem)
{
if (SKU(sku) != null)
return false;
Line line = new Line(sku, description);
line._Stock = new DiscreteStock(line, weightPerItem);
_SaleLines.Add(line);

return true;
}

public static bool CreateWeighedLine(string sku, string description,


double defaultSize)
{
if (SKU(sku) != null)
return false;

Line line = new Line(sku, description);


line._Stock = new WeighedStock(line, defaultSize);
_SaleLines.Add(line);

return line != null;


}

public bool Purchase(StockQuantity quantity, out Item items)


{
return _Stock.Purchase(quantity, out items);
}

public override string ToString()


{
return string.Format("{0} - {1,-40} Stock: {2}", _ProductSKU,
_Description, _Stock);
}
}
}
abstract class StockQuantity

class DiscreteStockQuantity: StockQuantity

public Quantity(int x)

class VolumeStockQuantity:StockQuantity

Quantity(double x)

}
class Item

int quantity;

string description;

double weight;

public item(int x)

qunatity=x;

public item(string x)

description=x;

public item(double x)

weight=x;

public override void display()

Console.writeline("item x= +x");

console.writeline("int x= qunatity");

console.writeline("double x=weight");

console.writeline("string =description");

}
}

class receipt

{int list;

public GETTEXT()

abstract class stock

int line;

public abstract void adjuststock(stockquantity quantity);

public abstract bool purchase(stockqunatity quantity, out item item);

public abstract void restock();

class discretestock:stock

int stored stock;

intshelfstock;

double weightperitem;

class weighedstock:stock

double storedstock;

double shelfstock;

doube defaultpurchase;

}
}

You might also like