olleeee
Binding problems, property not updating
Hi, im currently creating a snakes and ladders game where the user get to roll a dice and then move a gamepiece by it self on a board with numbered squares. The other player is a CPU and rolls the dice and moves automatically when its the CPUs turn. When landing on a ladder the player goes up to a new square, and on an snake it goes down. But i also want to implement a certain feature where if you land on a certain tile in the gameboard you swap positions with the other player. This is now only working for the cpu, and the cpu lands on the other humanplayer but the humanplayer still stands on the same tile and doesnt automatically goes to the cpus tile. I feel like it is a binding problem but don't really understand it since it works for the CPU and have implemented the same sort of code. Please Help!!
7 replies
creating objects in a different class
Hi, i have just gotten some feedback from handing in a project, my professors says that i have made some errors. I have corrected them but was wondering if anybody could just look through it and see if the comments in agreeing with the changes? https://discord.com/channels/143867839282020352/1181094353683365958/1181094353683365958 here is the code and will post the feedback underneath
5 replies
✅ Lists is the same index all the time.
Hi, i have built different lists for different houses in Hogwarts and now Im trying to add members to the different houses through a sorting hat method. But every time the same house just get members added, why?
41 replies
✅ Combobox writes out collection instead of the values
Hi im working in a WPF application for a university project thats based on Harry Potter. So i have built Hogwarts, and then put in the different houses, Gryffendor and so and so in different classes and built them after a house class to follow the same criteria. So the story is that you supposed to put in a password, and then fill in in a combobox which house the password is for. But when I do the combobox like bellow it just says collection, and not the differnt houses, why? Also added more code into here: https://paste.mod.gg/
39 replies
✅ Methods
Hi, i need help building a method to see if a textbox contains digits or letters. The assignment is to put in the year you are born and then give back how old you are. The tricky part for me is to build a method that will catch if you put letters in your textbox and not break down. Im not allowed to use any built in methods like tryParse och try and catch. ```cs
private void Button_Click(object sender, RoutedEventArgs e)
{
string yearBorn = TxtYearBorn.Text;
bool istrueornot = TryifStringisNumber(yearBorn);
if (istrueornot == false) { MessageBox.Show("Du får bara skriva in siffror"); } else if (istrueornot == true) { int integerYearBorn = int.Parse(yearBorn); int yearBornResult = Age(integerYearBorn); MessageBox.Show($"You are {yearBornResult} years old"); } } public bool TryifStringisNumber(string yearborn) { for (int i = 0; i < yearborn.Length; i++) { if (i <= 0 ) { return false; } else {
return true; } } return false; } private int Age(int yearOfBirth) { if (yearOfBirth >= 0) { return -1; } else { int currentyear = DateTime.Now.Year; return currentyear - yearOfBirth; } }
} }
if (istrueornot == false) { MessageBox.Show("Du får bara skriva in siffror"); } else if (istrueornot == true) { int integerYearBorn = int.Parse(yearBorn); int yearBornResult = Age(integerYearBorn); MessageBox.Show($"You are {yearBornResult} years old"); } } public bool TryifStringisNumber(string yearborn) { for (int i = 0; i < yearborn.Length; i++) { if (i <= 0 ) { return false; } else {
return true; } } return false; } private int Age(int yearOfBirth) { if (yearOfBirth >= 0) { return -1; } else { int currentyear = DateTime.Now.Year; return currentyear - yearOfBirth; } }
} }
37 replies
✅ Why is a variable false in project in WPF .Net application even after it should be true?
Hi I'm currently building my first C# project and could really need some help, I'm supposed to take in a password, check if it is correct to the declared passwords in properties and then be able to change the password if the new password follows the right format. Most of the code i have done but struggling a bit now, so could really really need some help.
87 replies