static void Main(string[] args) { List <Variation> variations = new List <Variation>() { new ColorVariation(), new SizeVariation(), new FabricVariation() }; Console.WriteLine("Hello,What tshirt color u want?"); var colorInput = Console.ReadLine().Trim().ToUpper(); var color = SetColor(colorInput); Console.WriteLine("How about Size?"); var sizeInput = Console.ReadLine().Trim().ToUpper(); var size = SetSize(sizeInput); Console.WriteLine("Material?"); var fabricInput = Console.ReadLine().Trim().ToUpper(); var fabric = SetFabric(fabricInput); Console.WriteLine("Choose Payment Method 1) Credit Card 2) Cash 3) Bank Transfer"); var paymentInput = Convert.ToInt32(Console.ReadLine().Trim()); var tShirt = new TShirt(color, size, fabric); var eshop = new Eshop(); eshop.SetVariationStrategy(variations); eshop.SelectPaymentMethod(paymentInput); eshop.PayTShirt(tShirt); }
public static Product ChooseProduct() { var sbProduct = new StringBuilder(); sbProduct .Append("What would you like to purchase today?") .AppendLine() .Append("1. T-Shirts") .AppendLine() .AppendLine("2. Nothing"); Console.Write(sbProduct); string productChoice = Console.ReadLine(); Product product; switch (productChoice) { case "1": case "T-Shirt": product = new TShirt(); break; case "2": case "Nothing": default: product = new NoProduct(); break; } return(product); }
static void Main(string[] args) { var basket = new Basket(); var shirt = new TShirt(); shirt.Name = "Dc Shirt"; shirt.Size = "m"; basket.shirts.Add(shirt); var golfer = new Golfer(); golfer.Name = "Old Khaki Golfer"; golfer.Size = "l"; basket.shirts.Add(golfer); var jeans = new Jeans(); jeans.Name = "Levis Jeans"; jeans.Size = "s"; basket.pants.Add(jeans); var formalpants = new FormalPants(); formalpants.Name = "Formal Pants"; formalpants.Size = "m"; basket.pants.Add(formalpants); Console.WriteLine($"Your total price is {basket.GetTotalPrice()}"); Console.ReadKey(); }
public static int partitionOrderByAccending(TShirt[] arr, int low, int high) { TShirt pivot = arr[high]; int i = (low - 1); for (int j = low; j < high; j++) { if (arr[j].Color > pivot.Color) { i++; TShirt temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } } TShirt temp1 = arr[i + 1]; arr[i + 1] = arr[high]; arr[high] = temp1; return(i + 1); }
public void DoPayment(TShirt tshirt) { decimal basePrice = 0.0m; switch (tshirt.Fabric) { case Fabric.WOOL: case Fabric.COTTON: basePrice = 20.0m; break; case Fabric.POLYESTER: case Fabric.RAYON: basePrice = 15.0m; break; case Fabric.LINEN: case Fabric.CASHMERE: case Fabric.SILK: basePrice = 30.0m; break; } switch (tshirt.Size) { //The price changes only for these sizes case Size.L: case Size.XL: case Size.XXL: case Size XXXL: basePrice += basePrice * 0.05m; break; } //The price is the same for all colors Console.WriteLine($"The price of your T-Shirt is: {basePrice:0.##}\u20AC"); }
private bool moreMulti(TShirt a, TShirt b) { if ((int)a.Size > (int)b.Size) { return(true); } if ((int)a.Size < (int)b.Size) { return(false); } if ((int)a.Color > (int)b.Color) { return(true); } if ((int)a.Color < (int)b.Color) { return(false); } if ((int)a.Fabric > (int)b.Fabric) { return(true); } else { return(false); } }
static void Main(string[] args) { var basket = new Basket(); var tshirt = new TShirt(); tshirt.Name = "RedBat"; tshirt.Size = "m"; basket.Shirts.Add(tshirt); var golfer = new Golfer(); golfer.Name = "Polo"; golfer.Size = "s"; basket.Shirts.Add(golfer); var fomalPants = new FormalPants(); fomalPants.Name = "Denim"; fomalPants.Size = "m"; basket.Pants.Add(fomalPants); var jeans = new Jeans(); jeans.Name = "Adidas"; jeans.Size = "l"; basket.Pants.Add(jeans); Console.WriteLine("Your total price is " + basket.GetTotalPrice().ToString("c")); Console.ReadKey(); }
private static int QuickSizeSortPartitionDesc(TShirt[] arr, int low, int high) { TShirt pivot = arr[high]; // index of smaller element int i = (low - 1); for (int j = low; j < high; j++) { // If current element is smaller // than the pivot if (arr[j].Size > pivot.Size) { i++; // swap arr[i] and arr[j] TShirt temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } } // swap arr[i+1] and arr[high] (or pivot) TShirt temp1 = arr[i + 1]; arr[i + 1] = arr[high]; arr[high] = temp1; return(i + 1); }
private bool multiLess(TShirt s1, TShirt s2) { if ((int)s1.Size < (int)s2.Size) { return(true); } if ((int)s1.Size > (int)s2.Size) { return(false); } if ((int)s1.Color < (int)s2.Color) { return(true); } if ((int)s1.Color > (int)s2.Color) { return(false); } if ((int)s1.Fabric < (int)s2.Fabric) { return(true); } else { return(false); } }
static void Main(string[] args) { var basket = new Basket(); var tshirt = new TShirt(ProductSize.S); tshirt.Name = "DC Comics"; basket.AddProduct(tshirt); var golfer = new Golfer(ProductSize.M); golfer.Name = "Lacoste"; basket.AddProduct(golfer); var jean = new Jeans(ProductSize.L); jean.Name = "Levis"; basket.AddProduct(jean); var formal = new FormalPants(ProductSize.M); formal.Name = "Chinos"; basket.AddProduct(formal); Console.WriteLine($"Your total price is R{basket.GetTotalPrice()}"); Console.Read(); }
protected override void OnAppearing() { base.OnAppearing(); var TShirt = new TShirt(); BindingContext = TShirt; }
public void KeyGenerationOnLoad() { using (var store = GetDocumentStore()) { //store.Conventions.RegisterIdConvention<TShirt>((databaseName, entity) => "ts/" + entity.ReleaseYear); store.Conventions.RegisterAsyncIdConvention <TShirt>((databaseName, entity) => new CompletedTask <string>("ts/" + entity.ReleaseYear)); store.Conventions.RegisterIdLoadConvention <TShirt>(id => "ts/" + id); using (var session = store.OpenSession()) { var shirt = new TShirt { Manufacturer = "Test1", ReleaseYear = 1999 }; session.Store(shirt); session.SaveChanges(); } using (var session = store.OpenSession()) { var shirt = session.Load <TShirt>(1999); Assert.Equal(shirt.Manufacturer, "Test1"); Assert.Equal(shirt.ReleaseYear, 1999); } } }
public async Task <ActionResult <TShirt> > Create(TShirt product) { _context.TshirtInfo.Add(product); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetById), new { id = product.ID }, product)); }
private void InitialEnvironment() { _tShirtService = new Services.Implementation.TShirtService(_tShirtRepository.Object); //Set environment DontRefactor.Models.TShirt[] list = new TShirt[] { new TShirt() { Id = Guid.NewGuid(), Colour = "Blue", Name = "Xamarin C# T-Shirt", Price = 15.0, ShirtText = "C#, Xamarin" }, new TShirt() { Id = Guid.NewGuid(), Colour = "Black", Name = "New York Yankees T-Shirt", Price = 8.0, ShirtText = "NY" }, new TShirt() { Id = Guid.NewGuid(), Colour = "Green", Name = "Disney Sleeping Beauty T-Shirt", Price = 10.0, ShirtText = "Mirror mirror on the wall..." } }; _tShirtRepository.Setup(l => l.GetAll()).Returns(list.AsQueryable()); }
public static List <TShirt> SizeColorFabricDesc(List <TShirt> tshirts) { for (int i = 0; i < tshirts.Count() - 1; i++) { for (int j = 0; j < tshirts.Count() - i - 1; j++) { if (tshirts[j].Fabric < tshirts[j + 1].Fabric) { TShirt temp = tshirts[j]; tshirts[j] = tshirts[j + 1]; tshirts[j + 1] = temp; } if (tshirts[j].Color < tshirts[j + 1].Color) { TShirt temp = tshirts[j]; tshirts[j] = tshirts[j + 1]; tshirts[j + 1] = temp; } if (tshirts[j].Size < tshirts[j + 1].Size) { TShirt temp = tshirts[j]; tshirts[j] = tshirts[j + 1]; tshirts[j + 1] = temp; } } } return(tshirts); }
private List <TShirt> InsertionSortBucketMulti(List <TShirt> shirts) { TShirt temp; for (int i = 1; i < shirts.Count; i++) { TShirt currentShirt = shirts[i]; int pointer = i - 1; while (pointer >= 0) { if (_multiOrder(currentShirt, shirts[pointer])) { temp = shirts[pointer + 1]; shirts[pointer + 1] = shirts[pointer]; shirts[pointer] = temp; pointer--; } else { break; } } } return(shirts); }
public TShirt GetById(int id) { TShirt tShirt = null; using (SqlConnection connection = new SqlConnection(Settings.Default.connectionString)) { string query = $"SELECT * FROM TShirts WHERE Id = {id}"; using (SqlCommand command = new SqlCommand(query, connection)) { connection.Open(); using (SqlDataReader dataReader = command.ExecuteReader()) { if (dataReader.HasRows) { dataReader.Read(); tShirt = new TShirt { Id = int.Parse(dataReader["Id"].ToString()), Color = dataReader["Color"].ToString(), Quantity = int.Parse(dataReader["Quantity"].ToString()), Size = dataReader["Size"].ToString() }; } } } } return(tShirt); }
static void Main(string[] args) { var basket = new Basket(); var tshirt = new TShirt(); tshirt.Name = "DC Comics"; tshirt.Size = "m"; basket.Shirts.Add(tshirt); var golfer = new Golfer(); golfer.Name = "Golfer"; golfer.Size = "m"; basket.Shirts.Add(golfer); var formalPants = new FormalPants(); formalPants.Name = "Formal Pants"; formalPants.Size = "m"; basket.PantsList.Add(formalPants); var jeans = new Jeans(); jeans.Name = "Jeans"; jeans.Size = "m"; basket.PantsList.Add(jeans); Console.WriteLine($"Your total price is {basket.GetTotalPrice()}"); Console.Read(); }
//============================================= Partition ========================================================== protected static int Partition(List <TShirt> shirts, int low, int high, Check.comparison comparison) { TShirt pivot = shirts[high]; // index of smaller element TShirt temp; int i = (low - 1); for (int j = low; j < high; j++) { // If current element is smaller // than the pivot if (!comparison(shirts[j], pivot)) { i++; // swap arr[i] and arr[j] temp = shirts[i]; shirts[i] = shirts[j]; shirts[j] = temp; } } // swap arr[i+1] and arr[high] (or pivot) TShirt temp1 = shirts[i + 1]; shirts[i + 1] = shirts[high]; shirts[high] = temp1; return(i + 1); }
public async Task <IActionResult> Edit(int id, [Bind("TShirtID,Size")] TShirt tShirt) { if (id != tShirt.TShirtID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tShirt); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TShirtExists(tShirt.TShirtID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(tShirt)); }
private void AssertEqual(ProductEx p1, TShirt p2, double rate = 1) { Assert.AreEqual(p1.Id, p2.Id); Assert.AreEqual(p1.Name, p2.Name); Assert.AreEqual(p1.Price, p2.Price * rate); Assert.AreEqual(p1.Type, "T-Shirt"); }
public void CheckIfNotSame() { //Arrange var book = new Book(); var shirt = new TShirt(); //Assert Assert.AreNotSame(book, shirt); }
public void PayTShirt(TShirt tshirt) { foreach (var variation in _variations) { Console.WriteLine($"Applying {variation.GetType().Name}"); variation.Cost(tshirt); Console.WriteLine($"TShirt cost after applying {variation.GetType().Name} is: {tshirt.Price}"); } _paymentMethod.Pay(tshirt.Price); }
public static Product ToProduct(this TShirt tShirt) { return(new Product { Id = tShirt.Id, Name = tShirt.Name, Price = tShirt.Price, //FIXME: Prices REALLY should have been Decimal not Double... Type = "T-Shirt" //FIXME: Type really should be an enum... }); }
public async Task <IActionResult> Update(long id, TShirt product) { if (id != product.ID) { return(BadRequest()); } _context.Entry(product).State = EntityState.Modified; await _context.SaveChangesAsync(); return(NoContent()); }
public async Task <IActionResult> Create([Bind("TShirtID,Size")] TShirt tShirt) { if (ModelState.IsValid) { _context.Add(tShirt); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tShirt)); }
static int QuickSortBySizeThenColorTheFabricPartitionASC(List <TShirt> tShirts, int low, int high) { TShirt pivot = tShirts[high]; // index of smaller element int i = (low - 1); for (int j = low; j < high; j++) { // If current element is smaller // than the pivot if (tShirts[j].Size < pivot.Size) { i++; // swap arr[i] and arr[j] TShirt temp = tShirts[i]; tShirts[i] = tShirts[j]; tShirts[j] = temp; } else if (tShirts[j].Size == pivot.Size) { if (tShirts[j].Color < pivot.Color) { i++; // swap arr[i] and arr[j] TShirt temp = tShirts[i]; tShirts[i] = tShirts[j]; tShirts[j] = temp; } else if (tShirts[j].Color == pivot.Color) { if (tShirts[j].Fabric < pivot.Fabric) { i++; // swap arr[i] and arr[j] TShirt temp = tShirts[i]; tShirts[i] = tShirts[j]; tShirts[j] = temp; } } } } // swap arr[i+1] and arr[high] (or pivot) TShirt temp1 = tShirts[i + 1]; tShirts[i + 1] = tShirts[high]; tShirts[high] = temp1; return(i + 1); }
public static void PrintOutSingle(TShirt tshirt) { var sb = new StringBuilder(); sb .AppendLine("Price\t\tColor\t\tSize\t\tFabric") .Append('-', 60) .AppendLine() .AppendLine($"{tshirt.Price}\t\t{tshirt.Color}\t\t{tshirt.Size}\t\t{tshirt.Fabric}"); Console.WriteLine(sb.ToString()); }
public void TestSale3() { var cart = new Cart(); var sale3 = new Sale3 <TShirt>(1, 11); var tshirt = new TShirt(10); cart.AddProduct(tshirt); cart.AddProduct(new Product(10)); cart.AddSale(sale3); //Cart price should be $10 Assert.Equal(10, cart.Calculate()); }
public void TestSale1() { var cart = new Cart(); var sale1 = new Sale1(0.9m); var tshirt = new TShirt(10); cart.AddProduct(tshirt); cart.AddProduct(new Product(10)); cart.AddSale(sale1); //Cart price should be $18 Assert.Equal(18, cart.Calculate()); }
private IEnumerable<TShirt> GetSampleData() { var tShirt1 = new TShirt { Name = "Wolf", BarcodeNumber = 10001, Types = new List<TShirtType> { new TShirtType { Color = "Blue", Size = "Small" }, new TShirtType { Color = "Black", Size = "Small" }, new TShirtType { Color = "Black", Size = "Medium" }, new TShirtType { Color = "Gray", Size = "Large" } } }; var tShirt2 = new TShirt { Name = "Wolf", BarcodeNumber = 1, Types = new List<TShirtType> { new TShirtType { Color = "Blue", Size = "Small" }, new TShirtType { Color = "Black", Size = "Large" }, new TShirtType { Color = "Gray", Size = "Medium" } } }; var tShirt3 = new TShirt { Name = "Owl", BarcodeNumber = 99999, Types = new List<TShirtType> { new TShirtType { Color = "Blue", Size = "Small" }, new TShirtType { Color = "Gray", Size = "Medium" } } }; var tShirt4 = new TShirt { Name = "Wolf", BarcodeNumber = -999, Types = new List<TShirtType> { new TShirtType { Color = "Blue", Size = "Small" }, new TShirtType { Color = "Black", Size = "Small" }, new TShirtType { Color = "Black", Size = "Medium" }, new TShirtType { Color = "Gray", Size = "Large" } } }; var tShirt5 = new TShirt { Name = "Wolf", BarcodeNumber = 10002, Types = new List<TShirtType> { new TShirtType { Color = "Blue", Size = "Small" }, new TShirtType { Color = "Gray", Size = "Large" } } }; var tShirt6 = new TShirt { Name = "Wolf", BarcodeNumber = 10003, Types = new List<TShirtType> { new TShirtType { Color = "Blue", Size = "Small" }, new TShirtType { Color = "Gray", Size = "Large" } } }; var tShirt7 = new TShirt { Name = "Wolf", BarcodeNumber = 10004, Types = new List<TShirtType> { new TShirtType { Color = "Blue", Size = "Small" }, new TShirtType { Color = "Gray", Size = "Large" } } }; var tShirt8 = new TShirt { Name = "Wolf", BarcodeNumber = 10005, Types = new List<TShirtType> //Doesn't MAtch SUB-QUERIES { new TShirtType { Color = "Blue", Size = "Small" }, new TShirtType { Color = "Gray", Size = "Medium" } } }; var tShirt9 = new TShirt { Name = "Wolf", BarcodeNumber = 10006, Types = new List<TShirtType> { new TShirtType { Color = "Blue", Size = "Small" }, new TShirtType { Color = "Gray", Size = "Large" } } }; yield return tShirt1; yield return tShirt2; yield return tShirt3; yield return tShirt4; yield return tShirt5; yield return tShirt6; yield return tShirt7; yield return tShirt8; yield return tShirt9; }