Program
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.Http.Headers;
using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;
using GeneralExercises;
using Microsoft.VisualBasic;
using static Lessons.Lesson1;
using static Lessons.Lesson1.Cheddar.TomatoSauce.Mozzarella.Ingredient.Cheddar.TomatoSauce.Mozzarela;
namespace Lessons
{
public class Lesson1
{
public class Pizza
{
public List<Ingredient> ingredients { get; set; } = new List<Ingredient>();
public decimal price = 10;
public virtual void pizzaSizze()
{
int size = 0;
string sizeOfPizza = "small";
string sizeOfPizza1 = "medium";
string sizeOfPizza2 = "large";
string sizeOfPizza3 = "extra large";
}
public virtual void kataskeuastis()
{
Console.WriteLine("topiko katastima");
}
public void AddIngredient(Ingredient ingredient)
{
ingredients.Add(ingredient);
}
public void Describe()
{
Ingredient cheddar = new Ingredient();
cheddar.Name = "Cheddar";
Ingredient tomatoSauce = new Ingredient();
tomatoSauce.Name = "Tomato Sauce";
Ingredient mozzarella = new Ingredient();
mozzarella.Name = "Mozzarella";
ingredients.Add(cheddar);
ingredients.Add(tomatoSauce);
ingredients.Add(mozzarella);
Console.WriteLine("Your pizza has the following ingredients:");
foreach (var ingredient in ingredients)
{
Console.WriteLine(ingredient.Name);
}
}
public void TakeAwayOrder(bool isTakeAway, decimal price)
{
if (isTakeAway)
{
Console.WriteLine($"The price is {price} + 2");
}
else
{
Console.WriteLine($"The price is {price}");
}
}
public void DeliveryOrder(bool isDelivery, decimal price)
{
if (isDelivery)
{
Console.WriteLine($"The price is {price} + 5");
}
else
{
Console.WriteLine($"The price is {price}");
}
}
}
public class aboutPizza : Pizza
{
public void aboutPizza1()
{
Console.WriteLine("our pizza is made with the best ingredients");
}
public override void pizzaSizze()
{
string sizeOfPizza = "small";
string sizeOfPizza1 = "medium";
string sizeOfPizza2 = "large";
string sizeOfPizza3 = "extra large";
Console.WriteLine("choose the size of the pizza you want");
int userInput = Convert.ToInt32(Console.ReadLine());
if (userInput == 1)
{
Console.WriteLine(sizeOfPizza);
}
else if (userInput == 2)
{
Console.WriteLine(sizeOfPizza1);
}
else if (userInput == 3)
{
Console.WriteLine(sizeOfPizza2);
}
else if (userInput == 4)
{
Console.WriteLine(sizeOfPizza3);
}
else
{
Console.WriteLine("wrong choice");
}
Console.WriteLine(string.Concat(pizzaSizze, userInput));
}
}
public class Ingredient
{
public int id;
public string Name { get; set; }
public decimal priceExtra;
}
public class Cheddar : Ingredient
{
public int AgedForMonths { get; set; }
public new decimal priceExtra { get; set; }
public Cheddar(decimal priceExtra, int agedForMonths)
{
AgedForMonths = agedForMonths;
this.priceExtra = priceExtra;
}
public class TomatoSauce : Ingredient
{
public int howmanyML { get; set; }
public new decimal priceExtra { get; set; }
public TomatoSauce()
{
howmanyML = 100;
priceExtra = 1;
}
public class Mozzarella : Ingredient
{
public bool IsLight { get; set; }
public new decimal priceExtra { get; set; }
public Mozzarella()
{
IsLight = true;
priceExtra = 1;
}
public class Ingredient
{
public int id;
public string Name { get; set; }
public decimal priceExtra;
public Ingredient() { }
public virtual void IngrediendCategory()
{
String sweet = "sweet";
String salty = "salty";
int howMany = 0;
}
public class Cheddar : Ingredient
{
public int AgedForMonths { get; set; }
public decimal priceExtra { get; set; }
public Cheddar(decimal priceExtra, int AgeForMonths)
{
this.AgedForMonths = AgeForMonths;
this.priceExtra = 2;
}
public class TomatoSauce : Ingredient
{
public int howmanyML { get; set; }
public decimal priceExtra { get; set; }
public TomatoSauce()
{
this.howmanyML = 100;
this.priceExtra = 1;
}
public class Mozzarela : Ingredient
{
public bool IsLight { get; set; }
public decimal priceExtra { get; set; }
public Mozzarela()
{
this.IsLight = true;
this.priceExtra = 1;
}
public class typeOfIngridients : Ingredient
{
public void typeOpPizza()
{
Console.WriteLine("choose the type of pizza you want");
Console.WriteLine("\n 1 for sweet and 2 for salty");
int userInput = Convert.ToInt32(Console.ReadLine());
if (userInput == 1)
{
Console.WriteLine("sweet");
}
else if (userInput == 2)
{
Console.WriteLine("salty");
}
else
{
Console.WriteLine("wrong choice");
}
}
public override void IngrediendCategory()
{
Console.WriteLine("\n our shop we have two types of pizzas");
Console.WriteLine("\n sweet and salty");
}
}
}
public static void Main(string[] args)
{
Ingredient ingredient = new Ingredient();
ingredient.Name = "Cheddar";
ingredient.priceExtra = 2;
ingredient.id = 1;
ingredient.Name = "Tomato Sauce";
ingredient.priceExtra = 1;
ingredient.id = 2;
ingredient.Name = "Mozzarella";
ingredient.priceExtra = 1;
ingredient.id = 3;
ingredient.Name = "Cheddar";
ingredient.priceExtra = 2;
ingredient.id = 1;
pizzasExtras pizzasExtras= new pizzasExtras();
pizzasExtras.MakeYourPizza();
pizzasExtras.searchForPizzas();
pizzasExtras.tropopoihsiProionton();
// katalogos katalogos = new katalogos();
// katalogos.CatalogosToChoose();
// katalogos.DeserdsCatalogos();
// katalogos.addItemsToDrinkCataloge();
// katalogos.readFromDrinksCATALOG();
// person person = new person(23, "q23", 32, "fdsds", "232", "dfesd");
// // manager manager = (manager)person;
// employee employee = (employee)person;
// person persp = manager;
//person pr = employee;
// manager.storemanaging();
// cardarob cardarob = new cardarob();
// cardarob.AddClothing();
/*
Pizza pizza = new Pizza();
pizza.DeliveryOrder(true, pizza.price);
pizza.TakeAwayOrder(true, pizza.price);
pizza.Describe();
AddondForPizza addondForPizza = new AddondForPizza();
addondForPizza.kataskeuastis();
sokolata sokolata = new sokolata();
sokolata.prostheseSokolata();
sokolata.apothemaKAImegethos();
typeOfIngridients typeOfIngridients = new typeOfIngridients();
typeOfIngridients.IngrediendCategory();
typeOfIngridients.typeOpPizza();
aboutPizza aboutPizza = new aboutPizza();
aboutPizza.aboutPizza1();
calculation calculation = new calculation();
calculation.calculateTotal();
*/
Console.WriteLine();
Console.ReadKey();
}
}
}
}
}
}
}
}
}
PizzaExtras
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;
namespace GeneralExercises
{
public class pizzasExtras
{
string[,] categories = new string[12, 12];
public void MakeYourPizza()
{
Console.WriteLine("Please enter the category of the pizza you want to add salty or sweet: ");
string category = Console.ReadLine() ?? string.Empty;
Console.WriteLine("Please enter the name of the pizza you want to add: ");
string pizzaname = Console.ReadLine() ?? string.Empty;
Console.WriteLine("Please enter the extra ingridients for the pizza you want to add: ");
string ingridient = Console.ReadLine() ?? string.Empty;
Console.WriteLine("Please enter the number of the extra ingridients for the pizza you want to add: ");
String ingridientnumber = Console.ReadLine() ?? string.Empty;
Console.WriteLine("Please enter the size of the pizza you want to add : small, medium, large, gigas ");
string size = Console.ReadLine() ?? string.Empty;
Console.WriteLine("Please enter the drinks of your preferense you want to add:");
string drinkname = Console.ReadLine() ?? string.Empty;
Console.WriteLine("Please enter the quantity of the pizza you want to add: ");
string quantitypizza = Console.ReadLine() ?? string.Empty;
Console.WriteLine("Please enter the quantity of the drinks you want to add: ");
string quantitydrinks = Console.ReadLine() ?? string.Empty;
Console.WriteLine("Please enter the desert you want to add: ");
string desert = Console.ReadLine() ?? string.Empty;
Console.WriteLine("Please enter the desert countitiy you want to add: ");
string desertcountity = Console.ReadLine() ?? string.Empty;
Console.WriteLine("Please enter your address: ");
string adress = Console.ReadLine() ?? string.Empty;
Console.WriteLine("Please enter your phone: ");
string phone = Console.ReadLine() ?? string.Empty;
for (int i = 0; i < categories.GetLength(0); i++)
{
for (int j = 0; j < categories.GetLength(1); j++)
{
if (categories[i, j] == null)
{
categories[0, 0] = category;
categories[i, 1] = pizzaname;
categories[i, 2] = phone;
categories[i, 3] = ingridient;
categories[i, 4] = ingridientnumber;
categories[i, 5] = size;
categories[i, 6] = drinkname;
categories[i, 7] = quantitydrinks;
categories[i, 8] = quantitypizza;
categories[i, 9] = desert;
categories[i, 10] = desertcountity;
categories[i, 11] = adress;
break;
}
}
}
}
public void searchForPizzas()
{
Console.WriteLine("αναζήτησε την πιτσα που σε ενδιαφέρει");
string userInput = Console.ReadLine() ?? string.Empty;
for (int i = 0; i < categories.GetLength(0); i++)
{
for (int j = 0; j < categories.GetLength(1); j++)
if (userInput.Contains(categories[11, 11]))
{
Console.WriteLine(categories);
}
}
foreach (string items in categories)
{
Console.WriteLine(items);
}
Console.WriteLine("mporeis na anazitiseis mia pizza me basi to onoma tis pizzas:");
for(int i=0; i < categories.Length; i++)
{
string pizzaName = Console.ReadLine() ?? string.Empty;
if (categories[i, 1] == userInput)
{
if(userInput==pizzaName)
Console.WriteLine(categories[i, 1]);
}
break;
}
}
public void tropopoihsiProionton()
{
string userInput = Console.ReadLine() ?? string.Empty;
for (int i = 0; i < categories.GetLength(0); i++)
{
for (int j = 0; j < categories.GetLength(1); j++)
if (categories[i, j] == userInput)
{
Console.WriteLine(categories[i, j]);
}
break;
}
string index = categories[11, 11];
if (index != null)
{
Console.WriteLine($"η πιτσα σου βρεθηκε στη θέση {index}.");
}
else
{
Console.WriteLine("η πιτσα σου δεν βρέθηκε.");
}
foreach (string items in categories)
{
Console.WriteLine(items);
}
Console.WriteLine("an eisai etoimos me tin paraggelia sou pata 1 an theleis na tin allakseis pata 2");
int userInput2 = Convert.ToInt32(Console.ReadLine());
if(userInput2!= null && userInput2==2)
{
Console.WriteLine("Please enter the category of the pizza you want to add salty or sweet: ");
categories[userInput2, 0]= Console.ReadLine() ?? string.Empty;
Console.WriteLine("Please enter the name of the pizza you want to add: ");
categories[userInput2, 1] = Console.ReadLine() ?? string.Empty; ;
Console.WriteLine("Please enter the extra ingridients for the pizza you want to add: ");
categories[userInput2, 2] = Console.ReadLine() ?? string.Empty;
Console.WriteLine("Please enter the number of the extra ingridients for the pizza you want to add: ");
categories[userInput2, 3] = Console.ReadLine() ?? string.Empty;
Console.WriteLine("Please enter the size of the pizza you want to add : small, medium, large, gigas ");
categories[userInput2, 4] = Console.ReadLine() ?? string.Empty;
Console.WriteLine("Please enter the drinks of your preferense you want to add:");
categories[userInput2, 5] = Console.ReadLine() ?? string.Empty;
Console.WriteLine("Please enter the quantity of the pizza you want to add: ");
categories[userInput2, 6] = Console.ReadLine() ?? string.Empty;
Console.WriteLine("Please enter the quantity of the drinks you want to add: ");
categories[userInput2, 7] = Console.ReadLine() ?? string.Empty;
Console.WriteLine("Please enter the desert you want to add: ");
categories[userInput2, 8] = Console.ReadLine() ?? string.Empty;
Console.WriteLine("Please enter the desert countitiy you want to add: ");
categories[userInput2, 9] = Console.ReadLine() ?? string.Empty;
Console.WriteLine("Please enter your address: ");
categories[userInput2, 10] = Console.ReadLine() ?? string.Empty;
Console.WriteLine("Please enter your phone: ");
categories[userInput2, 11] = Console.ReadLine() ?? string.Empty;
foreach (string items in categories)
{
Console.WriteLine(items);
}
}
else if (userInput2 == 1)
{
Console.WriteLine("your order will be delivered soon:");
}
foreach (string items in categories)
{
Console.WriteLine(items);
break;
}
}
}
}
catalog
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
//namespace GeneralExercises
//{
//public class katalogos
//{
// public void CatalogosToChoose()
// {
// Console.WriteLine("Choose from the following pizza catalog");
// string docPath = @"C:\Users\DE42QH\Documents\PizzaCtalog.txt";
// if (!(File.Exists(docPath)))
// {
// Console.WriteLine("The file does not exists");
// File.Create(docPath);
// }
// else if (File.Exists(docPath))
// {
// Console.WriteLine("The file exists");
// }
// for (int i = 0; i < docPath.Length; i++) // να το διορθωσω ωστε να γραψω πολλες σειρες
// {
// Console.WriteLine("write on catalog");
// string userInput = Convert.ToString(Console.ReadLine());
// string userIput2 = Convert.ToString(Console.ReadLine());
//try
//{
// TextWriter WriteAtext = new StreamWriter(docPath);
// WriteAtext.WriteLine(string.Concat(userInput, null));
// WriteAtext.WriteLine(string.Concat(null, userIput2));
// WriteAtext.Close();
//}
//catch (Exception e)
//{
//}
//TextWriter WriteAtext = new StreamWriter(docpath2);
//WriteAtext.WriteLine(userinput);
//WriteAtext.WriteLine(userInput2);
//WriteAtext.Close();
// }
//public void drinksCatalog()
//{
// Console.WriteLine("Choose from the following drinks catalog");
// string filePath3 = @"c:\users\DE42QH\Documents\DrinksCatalog.docx";
// File.Create(filePath3);
// if (!(File.Exists(filePath3)))
// {
// Console.WriteLine("The file does not exists");
// File.Create(filePath3);
// }
// else if (File.Exists(filePath3))
// {
// Console.WriteLine("The file exists");
// }
//}
//public void addItemsToDrinkCataloge()
//{
// Console.WriteLine("write the drinks you want to add to the catalog");
// string userInput = Convert.ToString(Console.ReadLine());
// string filePath3 = @"c:\users\DE42QH\Documents\DrinksCatalog.docx";
// TextWriter writeAtext = new StreamWriter(filePath3);
// //riteAtext.(userInput);
// writeAtext.Close();
//}
//public void readFromDrinksCATALOG()
//{
// String filePath3 = @"c:\users\DE42QH\Documents\DrinksCatalog.docx";
// TextReader readthetext = new StreamReader(filePath3);
// string readtex = readthetext.ReadLine();
// readthetext.Close();
//}
//public void readAllthecatalog()
//{
// String filePath3 = @"c:\users\DE42QH\Documents\DrinksCatalog.docx";
//TextReader readall = new TextReader(filepath3);
//List<string> reading = new List<string>();
//string temp;
//while ((temp = readall.ReadLine()) != null)
//{
// reading.Add(temp);
//}
// readall.Close();
// Console.WriteLine("the catalog contains:");
// foreach (string str in readall)
//{
// Console.WriteLine(str);
// }}}
employees
using System.Security.Cryptography.X509Certificates;
namespace GeneralExercises
{
public class person
{
public person(int id, string title, int age, string name, string description, string lastname)
{
this.id = id;
this.title = title;
this.age = age;
this.name = name;
this.description = description;
this.lastname = lastname;
}
public int id { get; set; }
public string title { get; set; }
public int age { get; set; }
public string name { get; set; }
public string description { get; set; }
public string lastname { get; set; }
void managing()
{
string domainOfmanaging;
Console.WriteLine("managing");
}
}
public class employee : person
{
public employee(int id, string title, int age, string name, string description, string lastname) : base(id, title, age, name, description, lastname)
{
}
double hourofwork = 40;
int daysOfWorkperMonth=25;
decimal grossSalary = 200m;
double daylyGrossSalary = 80;
double hourGrossSalary = 10;
public void convertGROSStoVALUE()
{
if (daysOfWorkperMonth==25 && hourofwork==40)
{
grossSalary = 2000m;
decimal value = 0.30m;
decimal finalSalary = grossSalary-value;
Console.WriteLine($" tha actualy salary is:{finalSalary}");
}
else if (daysOfWorkperMonth == 25 && hourofwork==20)
{
double finalsalary = daylyGrossSalary * 20;
}
}
}
public class manager : person
{
public manager(int id, string title, int age, string name, string description, string lastname) : base(id, title, age, name, description, lastname)
{
}
public void storemanaging()
{
Console.WriteLine( " store managing");
}
}
public class customer : person
{
public customer(int id, string title, int age, string name, string description, string lastname) : base(id, title, age, name, description, lastname)
{
}
public void buying()
{
Console.WriteLine("bying");
}
}
}
Addons
namespace GeneralExercises
{
public class AddondForPizza
{
string Magethos { get; set; } = " ";
int salty { get; set; }
int sweet { get; set; }
int howMnany { get; set; }
bool apothema { get; set; } = false;
public virtual void kataskeuastis()
{
Console.WriteLine("topiko katastima");
}
public virtual void kataskeuastis(string name)
{
Console.WriteLine("choose from where you want your pizza,,,! ");
Console.WriteLine("\n from a local pizza shop or from a franchise! ");
Console.WriteLine("choose 1 for local and 2 for a franchise and 3 for writing your favorite shop in another neighborhood ");
int userInput = Convert.ToInt32(Console.ReadLine());
if (userInput == 1)
{
Console.WriteLine("local pizza shop");
}
else if (userInput == 2)
{
Console.WriteLine("franchise pizza shop");
}
else if (userInput == 3)
{
Console.WriteLine("pizza shop from another neighborhood");
Console.WriteLine("\n write the name of the pizza shop");
string pizzaShop = Console.ReadLine();
if (!string.IsNullOrEmpty(pizzaShop))
{
Console.WriteLine(pizzaShop);
}
else
{
Console.WriteLine("wrong choice.");
Console.WriteLine("\n we choose local pizza shop for you");
}
}
}
}
public class sokolata : AddondForPizza
{
public string name { get; set; }
public int light { get; set; }
public int dark { get; set; }
public int white { get; set; }
public void apothemaKAImegethos()
{
Console.WriteLine("grapse ti leksi: sokolata, na deis an exoyme apothema kai ta megethoi poy exoyme");
string name3 = Convert.ToString(Console.ReadLine());
if (name3 == "sokolata")
{
Console.WriteLine("apothema KAI megethos DIATHESIMA");
Console.WriteLine(" \n MEGETHOS: 100, 200, 300");
}
else if (name3 == "SOKOLATA")
{
Console.WriteLine("apothema KAI 2 megethoi DIATHESIMA");
Console.WriteLine(" \n MEGETHOS: 100, 200");
}
else if (name3 == "Sokolata")
{
Console.WriteLine("apothema KAI 1 megethos DIATHESIMA");
Console.WriteLine(" \n MEGETHOS: 200");
}
else if (name3 == "Sokolatitsa")
{
Console.WriteLine("apothema KAI 1 megethos DIATHESIMA");
Console.WriteLine(" \n MEGETHOS: 100");
}
else if (name3 == "sokolatitsa")
{
Console.WriteLine("apothema KAI 1 megethos DIATHESIMA");
Console.WriteLine(" \n MEGETHOS: 300");
}
else if (name3 == "SOKOLATISA")
{
Console.WriteLine("apothema KAI TA 3 megethoi DIATHESIMA");
Console.WriteLine(" \n MEGETHOS: 100 200 300");
}
else
{
Console.WriteLine("den tha fas sokolAta");
}
}
public void prostheseSokolata()
{
Console.WriteLine("prosthese sokolata by choosing from the following selections: ");
Console.WriteLine("write the brand:");
var name = Convert.ToString(Console.ReadLine());
Console.WriteLine("add a choice from:");
Console.WriteLine("\n 1. light");
Console.WriteLine("\n 2. Dark");
Console.WriteLine("\n 3. white");
var name1 = Convert.ToInt32(Console.ReadLine());
if (name1 == 1)
{
Console.WriteLine("dark");
}
else if (name1 == 2)
{
Console.WriteLine("white");
}
else if (name1 == 3)
{
Console.WriteLine("light");
}
Console.WriteLine(String.Concat(name1, name));
}
}
public class calculation
{
decimal pizzaPricePerItem { get; set; } = 10m;
decimal sokolataPricePerItem { get; set; } = 5;
decimal total { get; set; }
decimal pizzaPriceDiscound { get; set; } = 3m;
public void calculateTotal()
{
Console.WriteLine("write the number of pizzas you want to buy");
int userInput = Convert.ToInt32(Console.ReadLine());
try
{
if (userInput == 1)
{
pizzaPricePerItem = 10m;
sokolataPricePerItem = 5m;
Console.WriteLine("the price of the pizza is:");
Console.WriteLine(string.Concat(pizzaPricePerItem," ", sokolataPricePerItem, " ", userInput));
}
else if (userInput == 2)
{
pizzaPricePerItem += 10m;
sokolataPricePerItem += 5m;
Console.WriteLine("the price of the 2 pizzas is:");
Console.WriteLine(string.Concat(pizzaPricePerItem, " ", sokolataPricePerItem, " ", userInput));
}
else if (userInput >= 3)
{
pizzaPricePerItem += 10m;
sokolataPricePerItem += 5m;
decimal totalDiscount = pizzaPricePerItem - pizzaPriceDiscound;
Console.WriteLine("the price of the 3 pizzas is:");
Console.WriteLine(string.Concat(pizzaPricePerItem, " ", sokolataPricePerItem, " ", totalDiscount, " ", userInput));
}
else
{
Console.WriteLine("wrong choice");
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.WriteLine("error");
}
}
}
}