using System;
using System.Collections.Generic;
namespace MedicineApp
{
class Medicine
{
private string medicineCode;
private string medicineName;
private string manufacturerName;
private float unitPrice;
private int quantityOnHand;
private string manufacturedDate;
private string expiryDate;
private int batchNumber;
public Medicine(string medicineCode, string medicineName, string manufacturerName,
float unitPrice, int quantityOnHand, string manufacturedDate, string expiryDate, int batchNumber)
{
this.medicineCode = medicineCode;
this.medicineName = medicineName;
this.manufacturerName = manufacturerName;
this.unitPrice = unitPrice;
this.quantityOnHand = quantityOnHand;
this.manufacturedDate = manufacturedDate;
this.expiryDate = expiryDate;
this.batchNumber = batchNumber;
}
public void displayInfo()
{
Console.WriteLine("Medicine code: {0} ", medicineCode);
Console.WriteLine("Medicine name: {0} ", medicineName);
Console.WriteLine("Manufacturer Name: {0} ", manufacturerName);
Console.WriteLine("Unit price: {0} ", unitPrice.ToString("N"));
Console.WriteLine("Quantity on Hand: {0} ", quantityOnHand);
Console.WriteLine("Manufactured Date: {0} ", manufacturedDate);
Console.WriteLine("Expiry Date: {0} ", expiryDate);
Console.WriteLine("Batch number: {0} ", batchNumber);
}
public void increaseQuantityOnhHand()
{
this.quantityOnHand = 50;
}
}
class Sales {
private List<Medicine> medicines=new List<Medicine>();
public Sales() { }
public void addMedicine(Medicine medicine)
{
this.medicines.Add(medicine);
}
public void display()
{
for (int i = 0; i < medicines.Count; i++)
{
medicines[i].displayInfo();
}
}
public void increaseQuantityOnhHand() {
for (int i = 0; i < medicines.Count; i++) {
medicines[i].increaseQuantityOnhHand();
}
}
}
class Program
{
static void Main(string[] args)
{
Sales sales = new Sales();
sales.addMedicine(new Medicine("455646", "Test name 1", "Medicine name 1", 45, 0, "05.05.2020", "05.05.2021",1346466));
sales.addMedicine(new Medicine("785545", "Test name 2", "Medicine name 2", 85, 0, "02.02.2021", "01.03.2022", 452124));
sales.addMedicine(new Medicine("454445", "Test name 3", "Medicine name 3", 36, 0, "06.01.2019", "08.07.2023", 1224545));
sales.display();
sales.increaseQuantityOnhHand();
sales.display();
Console.ReadLine();
}
}
}
Comments
Leave a comment