public void Chop(Mobile from) { if (from.InRange(this.GetWorldLocation(), 1)) { if (from == m_sower) { from.Direction = from.GetDirectionTo(this); double lumberValue = from.Skills[SkillName.Lumberjacking].Value / 100; if ((lumberValue > .5) && (Utility.RandomDouble() <= lumberValue)) { Mango fruit = new Mango(Utility.Random(m_yield + 2)); from.AddToBackpack(fruit); int cnt = Utility.Random(20) + 1; Log logs = new Log(cnt); from.AddToBackpack(logs); } this.Delete(); from.SendMessage("You chop the plant up"); } else { from.SendMessage("You do not own this plant !!!"); } } else { from.SendLocalizedMessage(500446); } }
public override void Dispose() { if (null != Mango) { Mango.Dispose(); } }
public AssetBundleLoader(string bundleName) { status = eLoadStatus.idle; this.bundleName = bundleName; path = ResourceSetting.GetBundlePathByBundleName(bundleName); resourceModule = Mango.GetModule <ResourceModule>(); taskModule = Mango.GetModule <TaskModule>(); }
public static void Main() { System.Console.WriteLine("Hello Interfaces"); Mango refDemo = new Mango(); refDemo.mymethod(); Orange refSample = new Orange(); refSample.mymethod(); }
public static void Main() { System.Console.WriteLine("Hello Interfaces"); abc refabc = new Mango(); refabc.mymethod(); abc refabd = new Orange(); refabd.mymethod(); Console.ReadLine(); }
public void Chop(Mobile from) { if (from.InRange(this.GetWorldLocation(), 1)) { if ((chopTimer == null) || (!chopTimer.Running)) { if ((TreeHelper.TreeOrdinance) && (from.AccessLevel == AccessLevel.Player)) { if (from.Region is Regions.GuardedRegion) { from.CriminalAction(true); } } chopTimer = new TreeHelper.ChopAction(from); Point3D pnt = this.Location; Map map = this.Map; from.Direction = from.GetDirectionTo(this); chopTimer.Start(); double lumberValue = from.Skills[SkillName.Lumberjacking].Value / 100; if ((lumberValue > .5) && (Utility.RandomDouble() <= lumberValue)) { Mango fruit = new Mango((int)Utility.Random(13) + m_yield); from.AddToBackpack(fruit); int cnt = Utility.Random((int)(lumberValue * 10) + 1); Log logs = new Log(cnt); // Fruitwood Logs ?? from.AddToBackpack(logs); FruitTreeStump i_stump = new FruitTreeStump(typeof(MangoTree)); Timer poof = new StumpTimer(this, i_stump, from); poof.Start(); } else { from.SendLocalizedMessage(500495); // You hack at the tree for a while, but fail to produce any useable wood. } //PublicOverheadMessage( MessageType.Regular, 0x3BD, false, string.Format( "{0}", lumberValue )); } } else { from.SendLocalizedMessage(500446); // That is too far away. } }
public void TestTowary() { Sklep sklep = new Sklep(); sklep.GetTowary(); Sklep mango = new Mango(); mango.GetTowary(); Sklep grycan = new Grycan(); grycan.GetTowary(); Sklep hAndM = new HAndM(); hAndM.GetTowary(); Sklep empik = new Empik(); empik.GetTowary(); }
static void Main(string[] args) { Employee prog = new Programmer(48091, "naynish p. chaughule", 85000, 500, "233-324-1246", new BenefitPlan("GWU", 3500)); ((Programmer)prog).CalculateIncentives(); Employee vp = new VicePresident(001, "henry w. gates", 150000, 200000, "343-325-9477", new BenefitPlan("DC Plan", 2573)); ((VicePresident)vp).CalculateIncentives(); foreach (var item in vp.GetMyPlanDetails()) { Console.WriteLine(item); } Console.WriteLine(vp.MyPlan.PlanName + " ends 06/07/2012"); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Programmer jay = new Programmer(); jay.CalculateIncentives(); VicePresident vp1 = new VicePresident(); vp1.CalculateIncentives(); //since InnerClass is private it is not exposed to the outside world //OuterClass.InnerClass obj = new OuterClass.InnerClass(); //cannot access the public members of the InnerClass Fruit f = new Fruit(); f.ShowFruitDetails(); Apple a = new Apple(); a.ShowFruitDetails(); Mango m = new Mango(); m.ShowFruitDetails(); //exception rule //reference of base class but instance of subclass: the method called with base class reference is virtual //and it is overridden in the sub class. Then the sub classes method would be called Fruit f1 = new Apple(); f1.ShowFruitDetails(); ((Apple)f1).Display(); f1.Display(); KashmirApple ka = new KashmirApple(); ka.ShowFruitDetails(); ka.Display(); Fruit f1ka = new KashmirApple(); f1ka.ShowFruitDetails(); f1ka.Display(); ((KashmirApple)f1ka).Display(); Apple ap1 = new Apple(); ap1.Display(); //i dont want this, i want the Display of the base class, cast it ((Fruit)ap1).Display(); //The first law of casting between class types is that when two classes are related by an “is-a” //relationship, it is always safe to store a derived object within a base class reference (implicit cast). HelperMethod(f); HelperMethod(a); HelperMethod(m); HelperMethod(f1); Object o = new Mango(); //Object o is pointing to a Fruit compatible class but that will not be known until runtime //HelperMethod(o); //not allowed //do a downward-cast, explicit casting is evaluated at runtime, not compile time HelperMethod((Mango)o); //demo of explicit cast evaluated at runtime VicePresident vpDemo = new VicePresident(); Object mng = new Mango(); try { vpDemo = (VicePresident)mng; //no compile time errors for this downward cast as it follows the inheritance chain //System.Object <-- VicePresident //run it and a runtime exception will be fired } catch (InvalidCastException e) { Console.WriteLine(e.Message); } //as and is does not require try catch //solution: determine at runtime whether a given type is compatible with another //vpDemo of VicePresident and mng of Object/mango vpDemo = mng as VicePresident; if (vpDemo == null) Console.WriteLine("Could not copy mng to vpDemo"); Fruit castFruit; Apple appDev = new Apple(); castFruit = appDev as Fruit; if (castFruit != null) Console.WriteLine("successful casting"); //In addition to the as keyword, the C# language provides the is keyword to determine whether two //items are compatible. Unlike the as keyword, however, the is keyword returns false, rather than a null //reference, if the types are incompatible. //check to see if mng is a VicePresident if (mng is VicePresident) //bool return value Console.WriteLine("casting possible"); else Console.WriteLine("casting not possible"); MasterParent mp1 = new MasterParent(); mp1.ShowDetials(); Console.ReadLine(); }
public DataTable Convert(Mango obj) { }
static void Main(string[] args) { int c; double total = 0; int pedidos = 0; char more = '1'; var pedido = new List <IHelado>(); var vasos = new List <IHelado> { new Barquillo(), new Canasta(), new Vaso() }; while (more != 's') { Console.Clear(); c = 0; Console.WriteLine("Helados"); Console.WriteLine("Recipiente"); foreach (var vaso in vasos) { c++; Console.WriteLine($"{c}: {vaso.GetDescripcion()}......{vaso.GetCosto()}"); } var read = int.Parse(Console.ReadKey().KeyChar.ToString()); switch (read) { case 1: pedido.Add(new Barquillo()); break; case 2: pedido.Add(new Canasta()); break; case 3: pedido.Add(new Vaso()); break; } Console.Clear(); Console.WriteLine("Cuantos Sabores de nieve?, Max 5 bolas"); var val = int.Parse(Console.ReadKey().KeyChar.ToString()); while (val > 5) { Console.Clear(); Console.WriteLine("Max 5 bolas, otra vez"); val = int.Parse(Console.ReadKey().KeyChar.ToString()); } for (int i = 0; i < val; i++) { Console.Clear(); Console.WriteLine($"Bola {i + 1}"); Console.WriteLine($"1. Limon...........$5.0"); Console.WriteLine($"2. Fresa...........$5.0"); Console.WriteLine($"3. Mango...........$6.0"); Console.WriteLine($"4. Chocolate.......$8.0"); Console.WriteLine($"5. ChocoChips......$8.0"); Console.WriteLine($"6. Vainilla........$7.0"); read = int.Parse(Console.ReadKey().KeyChar.ToString()); switch (read) { case 1: pedido[pedidos] = new Limon(pedido[pedidos]); break; case 2: pedido[pedidos] = new Fresa(pedido[pedidos]); break; case 3: pedido[pedidos] = new Mango(pedido[pedidos]); break; case 4: pedido[pedidos] = new Chocolate(pedido[pedidos]); break; case 5: pedido[pedidos] = new ChocoChips(pedido[pedidos]); break; case 6: pedido[pedidos] = new Vainilla(pedido[pedidos]); break; } } Console.Clear(); Console.WriteLine("Ingredientes Extras? [s][n]"); var extra = Console.ReadKey().KeyChar; if (extra is 's') { Console.Clear(); Console.WriteLine("Cuantos Ingredientes extras?,3 Max"); val = int.Parse(Console.ReadKey().KeyChar.ToString()); while (val > 3) { Console.Clear(); Console.WriteLine("Max 3, otra vez"); val = int.Parse(Console.ReadKey().KeyChar.ToString()); } for (int i = 0; i < val; i++) { Console.Clear(); Console.WriteLine($"Ingrediente Extra {i + 1}"); Console.WriteLine($"1. Chocolate Liquido...... $0.0"); Console.WriteLine($"2. ChocoKrispis............$0.50"); Console.WriteLine($"3. Lunetas.................$0.70"); Console.WriteLine($"4. ChispasColores..........$0.20"); Console.WriteLine($"5. Fresas..................$7.0"); Console.WriteLine($"6. Platano.................$5.0"); read = int.Parse(Console.ReadKey().KeyChar.ToString()); switch (read) { case 1: pedido[pedidos] = new ChocolateLiquido(pedido[pedidos]); break; case 2: pedido[pedidos] = new ChocoKrispis(pedido[pedidos]); break; case 3: pedido[pedidos] = new Lunetas(pedido[pedidos]); break; case 4: pedido[pedidos] = new ChispasColores(pedido[pedidos]); break; case 5: pedido[pedidos] = new Fresas(pedido[pedidos]); break; case 6: pedido[pedidos] = new Platano(pedido[pedidos]); break; } } } Console.Clear(); Console.WriteLine("Desea Finalizar su compra? [s][n]"); more = Console.ReadKey().KeyChar; if (more != 's') { pedidos++; } } Console.Clear(); Console.WriteLine("Su Pedido"); foreach (var ped in pedido) { total += ped.GetCosto(); Console.WriteLine($"{ped.GetDescripcion()}...............${ped.GetCosto()}"); } Console.WriteLine($"Total ${total}"); }
public AssetLoader(int id) { status = eLoadStatus.idle; resID = ResID.New(id); resourceModule = Mango.GetModule <ResourceModule>(); }
static void Main(string[] args) { int [] arra = new int[] { 20, 4, 8, 2 }; ASD(arra.Length, arra); arra = new int[] { 1, 2, 5, 10, 35, 89 }; ASD(arra.Length, arra); Hashtable h = new Hashtable(); Fill(/*ref*/ h); Console.WriteLine(h.Count); var a1 = "a df df d".Split(' '); var a3 = "h df ddf ad".Split(' '); var rest = a3.All(q => a3.Any(w => w == q)); Hashtable ht = new Hashtable(); ht.Add(1, 1); Dictionary <int, int> dic = new Dictionary <int, int>(); dic.Add(1, 2); //////////////////////////////////////////////// var i1 = 5; var i2 = new[] { 1, 2, 3 }; var zz = i2.Select(au => au * i1); foreach (var ty in zz) { i1 = ty; Console.WriteLine(ty); } //////////////////////////////////////////// try { throw new SpecificEx(); } catch (CustomException e) { } catch (Exception ex) { } Fruit aa = new Fruit(); Fruit bb = new Mango(); Mango cc = new Mango(); aa.MyName(); bb.MyName(); cc.MyName(); aa.func(); bb.func(); cc.func(); bool isEqual = FindIfSumOfNumbersIsEqualToN(new int[] { 1, 2, 3, 9 }, 8); isEqual = FindIfSumOfNumbersIsEqualToN(new int[] { 1, 2, 4, 4 }, 8); var resultArray = IncreaseNumberByOne(new int [] { 9, 9, 9 }); resultArray = IncreaseNumberByOne(new int[] { 7, 4, 9 }); resultArray = IncreaseNumberByOne(new int[] { 9, 2, 9, 3 }); resultArray = IncreaseNumberByOne(new int[] { 8, 2, 9, 3 }); printBinary(4); IntoToBinaryAndCountZeros(9); RotationAarrayKTimes(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, 3); int splitAnswers; splitAnswers = SplitInHalfBarackets("(())(()"); splitAnswers = SplitInHalfBarackets("()()((()))(()"); splitAnswers = SplitInHalfBarackets("((((((()))))))"); FastPowerSet <string>(new string[] { "abc" }); PowerSet("abc"); Console.WriteLine(IsFirstLetterUpperAndAllOtherabc("David")); Console.WriteLine(IsFirstLetterUpperAndAllOtherabc("dAvid")); Console.WriteLine(IsFirstLetterUpperAndAllOtherabc("D@vid")); Console.WriteLine(IsFirstLetterUpperAndAllOtherabc("123D")); TernaryTree ternaryST = new TernaryTree(); ternaryST.Add("abba"); ternaryST.Add("abc"); var ans = Split("9.0.5"); PrintStack ps = new PrintStack(); ps.Build(); ps.root.print(ps.root); int i = 5; object o_i = i; i = 3; Console.WriteLine(o_i); A a = new A(); B b = new B(); A a2 = new B(); Console.WriteLine(a.GetInt()); Console.WriteLine(b.GetInt()); Console.WriteLine(((A)b).GetInt()); Console.WriteLine(a2.GetInt()); Console.WriteLine("====================================================="); Console.WriteLine(a.GetBool()); Console.WriteLine(b.GetBool()); Console.WriteLine(((A)b).GetBool()); Console.WriteLine(a2.GetBool()); Console.WriteLine(Multiply(3, 4)); LINQ(); Output(); minimizeArray(); var aans = func("abcdef", "", "b"); subString("ababcabaa", "abc"); Car <object> c = new Car <object>(); //Object has default ctor. //Car<string> c = new Car<string>(); //String doesnt have default ctor. Convert.ToString("ss"); //Can handle nulls "dfdfdf".ToString(); //Cant handle nulls Check <int> comInt = new Check <int>(); comInt.Compare(1, 2); Check <string> comStr = new Check <string>(); comStr.Compare("David", "David"); int result; result = verify("---(++++)----"); // -> 1 Console.WriteLine("The string is: {0} output: {1}", "---(++++)----", result); result = verify(""); // -> 1 Console.WriteLine("The string is: {0} output: {1}", "", result); result = verify("before ( middle []) after "); // -> 1 Console.WriteLine("The string is: {0} output: {1}", "before ( middle []) after ", result); result = verify(") ("); // -> 0 Console.WriteLine("The string is: {0} output: {1}", ") (", result); result = verify("} {"); // -> 1 //no, this is not a mistake. Console.WriteLine("The string is: {0} output: {1}", "} {", result); result = verify("<( >)"); // -> 0 Console.WriteLine("The string is: {0} output: {1}", "<( >)", result); result = verify("( [ <> () ] <> )"); // -> 1 Console.WriteLine("The string is: {0} output: {1}", "( [ <> () ] <> )", result); result = verify(" ( [)"); // -> 0 Console.WriteLine("The string is: {0} output: {1}", " ( [)", result); //--------------------IEnumerable IEnumerator START----------------------- Person[] peopleArray = new Person[] { new Person("David", "Lesner"), new Person("Some", "Other"), new Person("Ampty", "Dumpty"), }; People peopleList = new People(peopleArray); foreach (Person p in peopleList) { Console.WriteLine(p.firstName + " " + p.lastName); } //--------------------IEnumerable IEnumerator END----------------------- List <Shape> shapes_list = new List <Shape>(); shapes_list.Add(new Triangle()); shapes_list.Add(new Circle()); shapes_list.Add(new Rectangle()); foreach (var shape in shapes_list) { shape.Print(); } }
static void Main(string[] args) { bool keepRunning = false; try{ foreach (Exception e in Storage.nonCriticalInitExceptions) { el(e); } }catch (Exception e) { el(e); return; } Storage.onMessage += (src, ex) => { if (src != null) { pl(src.ToString()); } if (ex.type == EventMessageType.error) { el(ex.msg); } else { pl(ex.msg); } }; do { if (keepRunning) { p("> "); string par = Console.ReadLine(); if (par == null) { par = ""; } if (par.StartsWith("> ")) { par = par.Substring(2); } args = argSplit(par); } if (args.Length < 1 || args[0].Length < 1) { keepRunning = true; } else { bool errorCmd = true; args[0] = args[0].ToLower(); switch (args[0]) { case "l": case "list": int pad = 10; if (args.Length > 1) { if (args[1].Equals("-s")) { if (args.Length >= 3) { SourceInfo si = SourceInfo.getExistingSource(args[2]); try{ List <ProtoMango> pms = si.listMangos(); if (pms == null) { pl("no data to display or method not implemented for source"); break; } pl("MANGOS \\ URL"); pl("".PadRight(pad * 3, '-')); pms.Sort(); foreach (ProtoMango pm in pms) { pl($"{pm.title}\n\t{pm.idStr})"); } }catch (Exception e) { el(e); } break; } pl("URL"); List <SourceInfo> sis = Storage.sources; sis.Sort(); sis.ForEach(si => pl(si.url)); break; } Mango m = Storage.mango(args[1]); if (m == null) { el("invalid mangoID, all valid mangoIDs can be listed with the list-command"); break; } List <MangoSlice> sls = m.slices; sls.Sort(); pl("CHAPTER".PadRight(pad, ' ') + "\tSOURCE + LOCATION + PAGES"); pl("".PadRight(pad * 3, '-')); foreach (MangoSlice sl in sls) { pl(sl.chapter.ToString().PadRight(pad, ' ') + $"\t{sl.source.url} || {sl.mango.id}/{sl.dir} ({sl.expectedPages})"); } break; } List <Mango> ms = Storage.mangos; ms.Sort(); pl("ID".PadRight(pad, ' ') + "\tTITLE"); pl("".PadRight(pad * 3, '-')); foreach (Mango m in ms) { pl(m.id.PadRight(pad, ' ') + "\t" + m.title); } break; case "a": case "add": if (args.Length == 2) { Mango m = Storage.addMangoByUrl(args[1]); pl($"Mango {m.title} ({m.id}) successfully added"); } else if (args.Length == 3) { Mango m = Storage.mango(args[1]); if (m == null) { el("invalid mangoID, all valid mangoIDs can be listed with the list-command"); break; } Storage.addMangoByUrl(args[2], m); pl($"Mango {m.title} ({m.id}) successfully expanded"); } else { el("invalid usage of 'add', requires one or two parameters:"); el("\tadd [<mangoID>] <source>"); break; } break; case "u": case "update": if (args.Length >= 2) { Mango m = Storage.mango(args[1]); if (m == null) { el("invalid mangoID, all valid mangoIDs can be listed with the list-command"); break; } try{ m.update(); pl($"Mango {m.title} ({m.id}) successfully updated"); }catch (Exception e) { el(e.Message); } } else { try{ Storage.updateAllMangos(ErrorHandling.stack); pl($"All Mango successfully updated"); }catch (ExceptionStack es) { foreach (Exception e in es.stack) { el(e.Message); } } } break; case "ul": case "updateload": if (args.Length >= 2) { Mango m = Storage.mango(args[1]); if (m == null) { el("invalid mangoID, all valid mangoIDs can be listed with the list-command"); break; } try{ m.update(); pl($"Mango {m.title} ({m.id}) successfully updated"); m.loadUnloadedSlices(); pl($"Mango {m.title} ({m.id}) successfully loaded"); }catch (Exception e) { el(e.Message); } } else { try{ Storage.updateAllMangos(ErrorHandling.stack); pl($"All Mango successfully updated"); Storage.loadAllUnloadedSlices(ErrorHandling.stack); pl($"All Mango successfully loaded"); }catch (ExceptionStack es) { foreach (Exception e in es.stack) { el(e.Message); } } } break; case "d": case "load": case "download": if (args.Length >= 2) { Mango m = Storage.mango(args[1]); if (m == null) { el("invalid mangoID, all valid mangoIDs can be listed with the list-command"); break; } try{ m.loadUnloadedSlices(); pl($"Mango {m.title} ({m.id}) successfully loaded"); }catch (Exception e) { el(e.Message); } } else { try{ Storage.loadAllUnloadedSlices(ErrorHandling.stack); pl($"All Mango successfully loaded"); }catch (ExceptionStack es) { foreach (Exception e in es.stack) { el(e.Message); } } } break; case "t": case "test": if (args.Length > 1) { try{ pl("loading data..."); pl(Storage.debugAddMangoByUrl(args[1], 1)); }catch (Exception e) { el(e.Message); } } else { el("invalid usage of 'test', requires one parameter:"); el("\ttest <source>"); break; } break; case "?": case "h": case "help": errorCmd = false; goto default; case "e": case "end": case "exit": keepRunning = false; break; default: if (errorCmd) { el($"unknown command {args[0]}"); } pl("Usage:"); pl("\t<Command> [<param> ...]"); pl("List of Commands:"); pl("\tadd, a"); pl("\t\tadds a new mango with source or a new source to an existing mango"); pl("\t\t\tadd [<mangoID>] <source>"); pl("\t\t\t\tmangoID: optional ID of existing mango"); pl("\t\t\t\tsource: the new source as an url. e.g. http://example.com/a-mango"); pl("\tdownload, load, d"); pl("\t\tloads all mangos or a specific one"); pl("\t\t\tdownload [<mangoID>]"); pl("\t\t\t\tmangoID: optional ID of existing mango"); pl("\texit, end, e"); pl("\t\tends this program"); pl("\thelp, h, ?"); pl("\t\tdisplays this help menu"); pl("\tlist, l"); pl("\t\tdisplays a list of all mangos"); pl("\t\t\tlist [<mangoID>]"); pl("\t\t\t\tmangoID: optional ID of existing mango; displays slices of mango if given"); pl("\t\t\tlist -s [<sourceUrl>]"); pl("\t\t\t\tsourceUrl: if given, attempts to display all mangos in source, otherwise all sources"); pl("\ttest, t"); pl("\t\ttests a plugin by attempting to add a mango"); pl("\t\t\tupdates <source>"); pl("\t\t\t\tsource: the new source as an url. e.g. http://example.com/a-mango"); pl("\tupdate, u"); pl("\t\tupdates all mangos or a specific one"); pl("\t\t\tupdates [<mangoID>]"); pl("\t\t\t\tmangoID: optional ID of existing mango"); pl("\tupdateload, ul"); pl("\t\tupdates and loads all mangos or a specific one"); pl("\t\t\tupdateload [<mangoID>]"); pl("\t\t\t\tmangoID: optional ID of existing mango"); break; } } }while(keepRunning); }
public override void OnDoubleClick(Mobile from) { if (from.Mounted && !TreeHelper.CanPickMounted) { from.SendMessage("You cannot pick fruit while mounted."); return; } if (DateTime.Now > lastpicked.AddSeconds(3)) // 3 seconds between picking { lastpicked = DateTime.Now; int lumberValue = (int)from.Skills[SkillName.Lumberjacking].Value / 20; if (from.Mounted) { ++lumberValue; } if (lumberValue < 0) //Changed lumberValue == 0 to lv < 0 { from.SendMessage("You have no idea how to pick this fruit."); return; } if (from.InRange(this.GetWorldLocation(), 2)) { if (m_yield < 1) { from.SendMessage("There is nothing here to harvest."); } else //check skill { from.Direction = from.GetDirectionTo(this); from.Animate(from.Mounted ? 26:17, 7, 1, true, false, 0); if (lumberValue < m_yield) //Changed lumberValue > to lv < 0 { lumberValue = m_yield + 1; } int pick = Utility.Random(lumberValue); if (pick == 0) { from.SendMessage("You do not manage to gather any fruit."); return; } m_yield -= pick; from.SendMessage("You pick {0} Mango{1}!", pick, (pick == 1 ? "" : "s")); //PublicOverheadMessage( MessageType.Regular, 0x3BD, false, string.Format( "{0}", m_yield )); Mango crop = new Mango(pick); from.AddToBackpack(crop); if (!regrowTimer.Running) { regrowTimer.Start(); } } } else { from.SendLocalizedMessage(500446); // That is too far away. } } }
protected override void Init() { resourceModule = Mango.GetModule <ResourceModule>(); }
protected override void OnInit() { Mango.GetModule <UpdateModule>().onUpdate.AddListener(Update); }
public void Visit(Mango mango) { Console.WriteLine($"Mangoes sold : {mango.Quantity}"); }
public void Visit(Mango mango) { Console.WriteLine($"Price after discount is {0.7*mango.Price}"); }
static void Main(string[] args) { var result = -1; var pedidos = new List <IHelado>(); var pedidoActual = 0; while (result == -1) { Console.Clear(); Console.WriteLine("Bienvenodo a la maquina de helados!!!"); Console.WriteLine("Vamos rapido con tu eleccion"); Console.WriteLine("Mire tengo estos recipientes para tu helado"); Console.WriteLine("1. Vaso $0.0"); Console.WriteLine("2. Barquillo $0.5"); Console.WriteLine("3. Canasta $ 1.0"); //pedidos.Add() var key = Console.ReadKey(); if (char.IsDigit(key.KeyChar)) { if (int.Parse(key.KeyChar.ToString()) == 1 || int.Parse(key.KeyChar.ToString()) == 2 || int.Parse(key.KeyChar.ToString()) == 3) { result = int.Parse(key.KeyChar.ToString()); //break; } } switch (result) { case 1: pedidos.Add(new Vaso()); break; case 2: pedidos.Add(new Barquillo()); break; case 3: pedidos.Add(new Canasta()); break; } pedidoActual = pedidos.Count - 1; int numeroBoalas = 0; result = -1; while (result != 7 && numeroBoalas < 6) { Console.Clear(); Console.WriteLine("Toca elegir el # de bolas maximo 5"); Console.WriteLine("Los Sabores:"); Console.WriteLine("1. Limon $5.0"); Console.WriteLine("2. Fresa $5.0"); Console.WriteLine("3. Mango $6.0"); Console.WriteLine("4. Chocolate $8.0"); Console.WriteLine("5. ChocoChips $8.0"); Console.WriteLine("6. Vainilla $7.0"); Console.WriteLine("7. No mas bolas"); key = Console.ReadKey(); if (char.IsDigit(key.KeyChar)) { if (int.Parse(key.KeyChar.ToString()) >= 1 && int.Parse(key.KeyChar.ToString()) <= 7) { result = int.Parse(key.KeyChar.ToString()); } } switch (result) { case 1: pedidos[pedidoActual] = new Limon(pedidos[pedidoActual]); numeroBoalas += 1; break; case 2: pedidos[pedidoActual] = new Fresa(pedidos[pedidoActual]); numeroBoalas += 1; break; case 3: pedidos[pedidoActual] = new Mango(pedidos[pedidoActual]); numeroBoalas += 1; break; case 4: pedidos[pedidoActual] = new Chocolate(pedidos[pedidoActual]); numeroBoalas += 1; break; case 5: pedidos[pedidoActual] = new ChocoChips(pedidos[pedidoActual]); numeroBoalas += 1; break; case 6: pedidos[pedidoActual] = new Vainilla(pedidos[pedidoActual]); numeroBoalas += 1; break; case 7: break; } } result = -1; int numeroExtras = 0; while (result != 7 && numeroExtras < 4) { Console.Clear(); Console.WriteLine("Toca elegir el # de ingredientes extra maximo 5"); Console.WriteLine("Los Extras:"); Console.WriteLine("1. Chocolate Liquido $0.0"); Console.WriteLine("2. ChocoKrispis $0.50"); Console.WriteLine("3. Lunetas $0.70"); Console.WriteLine("4. Chispas de Colores $0.20"); Console.WriteLine("5. Fresas $7.0"); Console.WriteLine("6. Platano $5.0"); Console.WriteLine("7. No mas extras"); key = Console.ReadKey(); if (char.IsDigit(key.KeyChar)) { if (int.Parse(key.KeyChar.ToString()) >= 1 && int.Parse(key.KeyChar.ToString()) <= 7) { result = int.Parse(key.KeyChar.ToString()); } } switch (result) { case 1: pedidos[pedidoActual] = new ChocolateLiquido(pedidos[pedidoActual]); numeroExtras += 1; break; case 2: pedidos[pedidoActual] = new ChocoKrispis(pedidos[pedidoActual]); numeroExtras += 1; break; case 3: pedidos[pedidoActual] = new Lunetas(pedidos[pedidoActual]); numeroExtras += 1; break; case 4: pedidos[pedidoActual] = new ChispasColores(pedidos[pedidoActual]); numeroExtras += 1; break; case 5: pedidos[pedidoActual] = new Fresas(pedidos[pedidoActual]); numeroExtras += 1; break; case 6: pedidos[pedidoActual] = new Platano(pedidos[pedidoActual]); numeroExtras += 1; break; case 7: break; } } Console.Clear(); Console.WriteLine("Ya está tu helado amigo!!!"); Console.WriteLine("Elige:"); Console.WriteLine("1. Otro helado"); Console.WriteLine("2. Ya nada, gracias"); //pedidos.Add() key = Console.ReadKey(); if (char.IsDigit(key.KeyChar)) { if (int.Parse(key.KeyChar.ToString()) == 1 || int.Parse(key.KeyChar.ToString()) == 2) { result = int.Parse(key.KeyChar.ToString()); } } switch (result) { case 1: result = -1; break; case 2: result = 99; break; } } foreach (var helado in pedidos) { Console.WriteLine($"{helado.ObtenerDescripcion()}....${helado.ObtenerCosto()}"); } }
public override void OnDoubleClick(Mobile from) { if (m_sower == null || m_sower.Deleted) { m_sower = from; } if (from != m_sower) { from.SendMessage("You do not own this plant !!!"); return; } if (from.Mounted && !CropHelper.CanWorkMounted) { from.SendMessage("You cannot harvest a crop while mounted."); return; } if (DateTime.UtcNow > lastpicked.AddSeconds(3)) { lastpicked = DateTime.UtcNow; int cookValue = (int)from.Skills[SkillName.Cooking].Value / 20; if (cookValue == 0) { from.SendMessage("You have no idea how to harvest this crop."); return; } if (from.InRange(this.GetWorldLocation(), 1)) { if (m_yield < 1) { from.SendMessage("There is nothing here to harvest."); } else { from.Direction = from.GetDirectionTo(this); from.Animate(from.Mounted ? 29:32, 5, 1, true, false, 0); m_lastvisit = DateTime.UtcNow; if (cookValue > m_yield) { cookValue = m_yield + 1; } int pick = Utility.RandomMinMax(cookValue - 4, cookValue); if (pick < 0) { pick = 0; } if (pick == 0) { from.SendMessage("You do not manage to harvest any crops."); return; } m_yield -= pick; from.SendMessage("You harvest {0} crop{1}!", pick, (pick == 1 ? "" : "s")); if (m_yield < 1) { ((Item)this).ItemID = pickedGraphic; } Mango crop = new Mango(pick); from.AddToBackpack(crop); if (!regrowTimer.Running) { regrowTimer.Start(); } } } else { from.SendMessage("You are too far away to harvest anything."); } } }