static void Main(string[] args) { string directory = $"{System.IO.Directory.GetCurrentDirectory()}\\FightClubXML"; FileInfo[] files = new DirectoryInfo(directory).GetFiles(); pc playerCharacter = new pc(); data collectionPlayerCharacter = new data(); XmlSerializer playerCharacterSerializer = new XmlSerializer(typeof(pc)); XmlSerializer collectionPlayerCharacterSerializer = new XmlSerializer(typeof(data)); foreach (FileInfo file in files) { try { using (FileStream fileStream = new FileStream(file.FullName, FileMode.Open)) { playerCharacter = (pc)playerCharacterSerializer.Deserialize(fileStream); PrintablePlayerCharacter _playerCharacter = new FightClubConverter.Converter(playerCharacter).Build(); } } catch (System.InvalidOperationException) { using (FileStream fileStream = new FileStream(file.FullName, FileMode.Open)) { collectionPlayerCharacter = (data)collectionPlayerCharacterSerializer.Deserialize(fileStream); } } } Console.WriteLine("Finished building character sheets!"); Console.WriteLine("You can exit now."); }
public Converter(pc playerCharacter) { if (playerCharacter != null) { this._pc = playerCharacter; } this._printablePlayerCharacter = new PrintablePlayerCharacter(); }
// Use this for initialization void Start() { statehand = sthand.GetComponent <StateofHand>(); r = roll.GetComponent <Roll>(); win = winner.GetComponent <Winner>(); playerhand = player.GetComponent <player>(); pcstate = pchand.GetComponent <pc>(); pcscr = _pcscore.GetComponent <pcscore>(); plscore = playerscore.GetComponent <playerscore>(); scorepc = 0; scoreplayer = 0; }
public void SaveNewItem() { try { using (var db = new course_work_Entities()) { var pcTypeS = from p in db.pc_type where p.name.Equals(pcTypeField.Text) select p; pc_type pcType; if (!pcTypeS.Any()) { pcType = new pc_type() { name = pcTypeField.Text, }; db.pc_type.Add(pcType); db.SaveChanges(); } else { pcType = pcTypeS.First(); } var producerS = from p in db.producers where p.name.Equals(producerField.Text) select p; producer producer; if (!producerS.Any()) { producer = new producer() { name = producerField.Text, }; db.producers.Add(producer); db.SaveChanges(); } else { producer = producerS.First(); } var pc = new pc() { name = nameField.Text, description = descriptionField.Text, pc_type1 = pcType, producer1 = producer }; db.pcs.Add(pc); db.SaveChanges(); Init(); } list.SelectedIndex = list.Items.Count - 1; } catch (Exception) { MessageBox.Show("Щось пішло не так", "Помилка"); } }
public Form1() { bus1 = new bus(); pc pc1 = new pc(); pc pc2 = new pc(); pcList.Add(pc1); pcList.Add(pc2); InitializeComponent(); label1.Text = pc1.state; }
/* * send(frame) * wait_until (end_of_frame) or (collision) * if collision detected: * stop transmitting * send(jamming) * k = min (10, N) * r = random(0, 2k - 1) * slotTime * wait(r*slotTime) */ public void send(bus bus1, pc act_pc) { act_pc.state = "want to send"; wait(bus1); bus1.state = "start_send"; // SO MUCH ANIMÁCIÓ // wait /* * if (state == "idle") * { * state = "want_to_send"; * if (bus1.state.Equals("empty")) * { * state = "start_send"; * bus1.state = "busy"; * state = "send"; * } * * } */ }
public static void Main(string[] args) { //abstract class Console.WriteLine("ABSTRACT CLASS"); Kuliah kuliah; kuliah = new Dosen(); kuliah.materi(); kuliah.tugas(); Console.WriteLine(); kuliah = new Mahasiswa(); kuliah.materi(); kuliah.tugas(); Console.WriteLine(); Console.WriteLine(); //interface Console.WriteLine("INTERFACE"); IKomputer komputer; komputer = new monitor(); komputer.info(); komputer.fungsi(); Console.WriteLine(); komputer = new pc(); komputer.info(); komputer.fungsi(); Console.WriteLine(); komputer = new keyboard(); komputer.info(); komputer.fungsi(); }
public Converter() { this._pc = new pc(); this._printablePlayerCharacter = new PrintablePlayerCharacter(); }
Router(pc, message.Split(' '));
static void Main(string[] args) { pc[] ordenadores = new pc[600]; char opcion = '0'; bool comprobacion = false; int index = 0; byte posicion_dato; string tempbrand = ""; string tempmodel = ""; int tempyear = 0; int tempsize = 0; string tempunit = ""; string tempcomments = ""; int dato = 0; for (int i = 0; i < 25; i++) { ordenadores[index].brand = "atari" + i; ordenadores[index].model = "45678" + i; ordenadores[index].year = 0; ordenadores[index].ram.unit = "kb"; ordenadores[index].ram.size = 8; ordenadores[index].comments = "viejo"; index++; } do { Console.WriteLine(" 1 - Add a new computer data" ); Console.WriteLine(" 2 - Show all brands and models of computers stored." ); Console.WriteLine(" 3 - Search for computers that contain a certain text" ); Console.WriteLine(" 4 - Update a record" ); Console.WriteLine(" 5 - Delete some data" ); Console.WriteLine(" 6 - Insert data in a position chosen" ); Console.WriteLine(" 7 - Sort the data alphabetically by brand+model." ); Console.WriteLine(" 8 - Remove extra spaces " ); Console.WriteLine(" Q - Quit"); string temp2 = Console.ReadLine(); opcion = '0'; if (temp2.Length > 0) { opcion = temp2[0]; } Console.WriteLine(""); switch (opcion) { case '1': // añade datos al final while (comprobacion == false) // tambien se puede con do-while { Console.WriteLine("Write a brand name to add:"); tempbrand = Console.ReadLine(); if (tempbrand != "" && tempbrand.Length < 50) { ordenadores[index].brand = tempbrand; comprobacion = true; } } comprobacion = false; Console.WriteLine("Write the model of the pc:"); tempmodel = Console.ReadLine(); ordenadores[index].model = tempmodel; Console.WriteLine("Write the manufacture year:"); int.TryParse(Console.ReadLine(), out tempyear); ordenadores[index].year = tempyear; Console.WriteLine("Write the unit measure for ram:"); tempunit = Console.ReadLine(); ordenadores[index].ram.unit = tempunit; Console.WriteLine("Write the size of the ram:"); int.TryParse(Console.ReadLine(), out tempsize); ordenadores[index].ram.size = tempsize; Console.WriteLine("Write some comments for this pc:"); tempmodel = Console.ReadLine(); ordenadores[index].comments = tempcomments; comprobacion = false; index++; break; case '2': if (index == 0) { Console.Write("there is no data to show"); } else { for (int i = 0; i < index; i++) { Console.WriteLine(ordenadores[i].brand + "-" + ordenadores[i].model); if ((i+1) % 2 == 0) { Console.WriteLine(); Console.WriteLine("Press enter to continue"); Console.ReadLine(); } } } Console.WriteLine(); break; case '3': //falta el case insensitive string busqueda = ""; bool encontrados = false; Console.WriteLine("Write the text to search"); busqueda = Console.ReadLine().ToLower(); for (int i = 0; i < index; i++) { if (ordenadores[i].brand.ToLower().Contains(busqueda) || ordenadores[i].model.ToLower().Contains(busqueda) || ordenadores[i].comments.ToLower().Contains(busqueda)) { Console.WriteLine(ordenadores[i].brand); Console.WriteLine(ordenadores[i].model); if(ordenadores[i].year == 0) { Console.WriteLine("year: unknown"); } else { Console.WriteLine(ordenadores[i].year); } Console.WriteLine(ordenadores[i].comments); Console.WriteLine(ordenadores[i].ram.unit); Console.WriteLine(ordenadores[i].ram.size); Console.WriteLine("_________________________"); encontrados = true; } } if (encontrados==false) Console.WriteLine("There is no data to show"); break; case '4': Console.WriteLine("introduzca el numero de dato a modificar"); if(int.TryParse(Console.ReadLine(), out dato) && dato <= index && dato > 0) { while (comprobacion == false) // tambien se puede con do-while { Console.WriteLine("Brand: "+ordenadores[dato].brand + " new brand?"); tempbrand = Console.ReadLine(); if (tempbrand.Length < 50) { if (tempbrand != "") { ordenadores[dato].brand = tempbrand; } comprobacion = true; } } comprobacion = false; // terminar de formatear con sus respectivos cambios Console.WriteLine("model: " + ordenadores[dato].model + " new model?"); tempmodel = Console.ReadLine(); if (tempmodel != "") ordenadores[dato].model = tempmodel; Console.WriteLine("Brand: " + ordenadores[dato].year + " new year?"); int.TryParse(Console.ReadLine(), out tempyear); ordenadores[dato].year = tempyear; Console.WriteLine("Write the unit measure for ram:"); tempunit = Console.ReadLine(); ordenadores[dato].ram.unit = tempunit; Console.WriteLine("Write the size of the ram:"); int.TryParse(Console.ReadLine(), out tempsize); ordenadores[dato].ram.size = tempsize; Console.WriteLine("Write some comments for this pc:"); tempmodel = Console.ReadLine(); ordenadores[dato].comments = tempcomments; } else { Console.WriteLine("se ha introducido un numero incorrecto"); } break; case '5': //borrar dato Console.WriteLine("introduzca el numero de dato a modificar"); if(int.TryParse(Console.ReadLine(), out dato) && dato<=index && dato>0) { for (int i = dato-1; i < index; i++) { //se puede optimizar en una linea ordenadores[i].brand = ordenadores[i+1].brand; ordenadores[i].model = ordenadores[i+1].model; ordenadores[i].year = ordenadores[i+1].year; ordenadores[i].ram.unit = ordenadores[i+1].ram.unit; ordenadores[i].ram.size = ordenadores[i+1].ram.size; ordenadores[i].comments = ordenadores[i+1].comments; } index--; } else { Console.WriteLine("se ha introducido un numero incorrecto"); } break; case '6': // INSERTAR DATOS Console.WriteLine("introduzca el numero de dato a modificar"); if(int.TryParse(Console.ReadLine(), out dato) && dato<=index) { for (int i = index-1; i >=dato-1 ; i--) { //se puede optimizar en una linea /*ordenadores[i+1].brand = ordenadores[i].brand ; ordenadores[i+1].model = ordenadores[i].model ; ordenadores[i+1].year = ordenadores[i].year ; ordenadores[i+1].ram.unit = ordenadores[i].ram.unit; ordenadores[i+1].ram.size = ordenadores[i].ram.size; ordenadores[i+1].comments = ordenadores[i].comments;*/ ordenadores[i+1] = ordenadores[i]; } index++; while (comprobacion == false) // tambien se puede con do-while { Console.WriteLine("Write a brand name to add:"); tempbrand = Console.ReadLine(); if (tempbrand != "" && tempbrand.Length < 50) { ordenadores[dato].brand = tempbrand; comprobacion = true; } } comprobacion = false; Console.WriteLine("Write the model of the pc:"); tempmodel = Console.ReadLine(); ordenadores[dato].model = tempmodel; Console.WriteLine("Write the manufacture year:"); int.TryParse(Console.ReadLine(), out tempyear); ordenadores[dato].year = tempyear; Console.WriteLine("Write the unit measure for ram:"); tempunit = Console.ReadLine(); ordenadores[dato].ram.unit = tempunit; Console.WriteLine("Write the size of the ram:"); int.TryParse(Console.ReadLine(), out tempsize); ordenadores[dato].ram.size = tempsize; Console.WriteLine("Write some comments for this pc:"); tempmodel = Console.ReadLine(); ordenadores[dato].comments = tempcomments; comprobacion = false; } else { Console.WriteLine("se ha introducido un numero incorrecto"); } break; case '7': string tipo; Console.WriteLine("introduzca marca si quiere ordenar por marca, o modelo si quiere ordenar por modelo "); tipo = Console.ReadLine(); if (tipo == "marca") { pc temp; for (int i = 1; i < ordenadores.Length; i++) { for (int j = ordenadores.Length - 1; j >= i; j--) { if (ordenadores[j - 1].brand.CompareTo(ordenadores[j].brand) > 0) { temp = ordenadores[j - 1]; ordenadores[j - 1] = ordenadores[j]; ordenadores[j] = temp; } } } } if (tipo == "modelo") { pc temp; for (int i = 1; i < ordenadores.Length; i++) { for (int j = ordenadores.Length - 1; j >= i; j--) { if (ordenadores[j - 1].model.CompareTo(ordenadores[j].model) > 0) { temp = ordenadores[j - 1]; ordenadores[j - 1] = ordenadores[j]; ordenadores[j] = temp; } } } } break; case '8': for (int i = 0; i < ordenadores.Length; i++) { while (ordenadores[i].brand[0] == ' ') { ordenadores[i].brand.Remove(0, 1); } while (ordenadores[i].brand[ordenadores[i].brand.Length - 1] == ' ') { ordenadores[i].brand.Remove(ordenadores[i].brand.Length - 1, 1); } while (ordenadores[i].model[0] == ' ') { ordenadores[i].model.Remove(0, 1); } while (ordenadores[i].model[ordenadores[i].model.Length - 1] == ' ') { ordenadores[i].model.Remove(ordenadores[i].model.Length - 1, 1); } while (ordenadores[i].comments[0] == ' ') { ordenadores[i].comments.Remove(0, 1); } while (ordenadores[i].comments[ordenadores[i].comments.Length - 1] == ' ') { ordenadores[i].comments.Remove(ordenadores[i].comments.Length - 1, 1); } } break; } } while (opcion != 'Q'); }
GiveRandomTreasure(pc, treasureName);
if (isEnoughRecyclePoints(pc, price) == true) {