✅ my program is acting weird

...
6 Replies
𓀠𓀒𓀡𓀬
𓀠𓀒𓀡𓀬OP10mo ago
this is the output: (its not doing the second method for some reason)
𓀠𓀒𓀡𓀬
𓀠𓀒𓀡𓀬OP10mo ago
No description
𓀠𓀒𓀡𓀬
𓀠𓀒𓀡𓀬OP10mo ago
here is the code
𓀠𓀒𓀡𓀬
𓀠𓀒𓀡𓀬OP10mo ago
this is where it should do the function which is not happing for some reason in this case its the drink function
Console.WriteLine("Would you like to play a little game with your parrot kind otherwise 'q' to quit:");
string user_second = Console.ReadLine().ToLower();
while (true)
{
if (user.Length > 1)
{
int move_meter = 0;
for (int i = 0; i < 2; i++)
{
Console.WriteLine();
Console.WriteLine("do you want to fly or walk");
string move = Console.ReadLine().ToLower();

if (move == "fly")
{
int user_fly = birds[birds.Length -1].Fly();
move_meter += user_fly;


}
else if (move == "walk")
{
int user_walk = birds[birds.Length -1].Walk();
move_meter += user_walk;
}

}
birds[birds.Length -1].eat(move_meter);
Console.WriteLine(birds[birds.Length -1].name);
Console.WriteLine(birds[birds.Length -1].food);
Console.WriteLine(birds[birds.Length -1].water);
Console.WriteLine(birds[birds.Length -1].health);
Console.WriteLine();
birds[birds.Length - 1].drink(move_meter);
Console.WriteLine(birds[birds.Length - 1].name);
Console.WriteLine(birds[birds.Length - 1].food);
Console.WriteLine(birds[birds.Length - 1].water);
Console.WriteLine(birds[birds.Length - 1].health);
Console.WriteLine();
}
Console.WriteLine("Would you like to play a little game with your parrot kind otherwise 'q' to quit:");
string user_second = Console.ReadLine().ToLower();
while (true)
{
if (user.Length > 1)
{
int move_meter = 0;
for (int i = 0; i < 2; i++)
{
Console.WriteLine();
Console.WriteLine("do you want to fly or walk");
string move = Console.ReadLine().ToLower();

if (move == "fly")
{
int user_fly = birds[birds.Length -1].Fly();
move_meter += user_fly;


}
else if (move == "walk")
{
int user_walk = birds[birds.Length -1].Walk();
move_meter += user_walk;
}

}
birds[birds.Length -1].eat(move_meter);
Console.WriteLine(birds[birds.Length -1].name);
Console.WriteLine(birds[birds.Length -1].food);
Console.WriteLine(birds[birds.Length -1].water);
Console.WriteLine(birds[birds.Length -1].health);
Console.WriteLine();
birds[birds.Length - 1].drink(move_meter);
Console.WriteLine(birds[birds.Length - 1].name);
Console.WriteLine(birds[birds.Length - 1].food);
Console.WriteLine(birds[birds.Length - 1].water);
Console.WriteLine(birds[birds.Length - 1].health);
Console.WriteLine();
}
this is the actualfunction:
public void drink(int meter)
{
// we should be able to drink
int meters = meter;
Random random = new Random();
int drink = random.Next(1, 50);
if (drink >= 1 && drink <= 10 && meters >= 1 && meters <= 15)
{
Console.WriteLine();
Console.WriteLine("you have not been walking for quite long and found some water (water goes up by 5)");
Console.WriteLine();
water += 5;
}
else if (drink > 10 && drink <= 20 && meters > 15 && meters <= 30)
{
Console.WriteLine();
Console.WriteLine("you have not been walking for quite long and found some water (water goes up by 10)");
Console.WriteLine();
water += 10;
}
else if (drink > 20 && drink <= 30 && meters > 30 && meters <= 45)
{
Console.WriteLine();
Console.WriteLine("you have not been walking for quite long and found some water (water goes up by 15)");
Console.WriteLine();
water += 15;
}
else if (drink > 30 && drink <= 40 && meters > 45 && meters <= 60)
{
Console.WriteLine();
Console.WriteLine("you have been walking for quite long and found some water (water goes up by 20)");
Console.WriteLine();
water += 20;
}
else if (drink > 40 && drink <= 50 && meters > 60 && meters <= 75)
{
Console.WriteLine();
Console.WriteLine("you have been walking for quite long and found some water (water goes up by 25)");
Console.WriteLine();
water += 25;
}
}
public void drink(int meter)
{
// we should be able to drink
int meters = meter;
Random random = new Random();
int drink = random.Next(1, 50);
if (drink >= 1 && drink <= 10 && meters >= 1 && meters <= 15)
{
Console.WriteLine();
Console.WriteLine("you have not been walking for quite long and found some water (water goes up by 5)");
Console.WriteLine();
water += 5;
}
else if (drink > 10 && drink <= 20 && meters > 15 && meters <= 30)
{
Console.WriteLine();
Console.WriteLine("you have not been walking for quite long and found some water (water goes up by 10)");
Console.WriteLine();
water += 10;
}
else if (drink > 20 && drink <= 30 && meters > 30 && meters <= 45)
{
Console.WriteLine();
Console.WriteLine("you have not been walking for quite long and found some water (water goes up by 15)");
Console.WriteLine();
water += 15;
}
else if (drink > 30 && drink <= 40 && meters > 45 && meters <= 60)
{
Console.WriteLine();
Console.WriteLine("you have been walking for quite long and found some water (water goes up by 20)");
Console.WriteLine();
water += 20;
}
else if (drink > 40 && drink <= 50 && meters > 60 && meters <= 75)
{
Console.WriteLine();
Console.WriteLine("you have been walking for quite long and found some water (water goes up by 25)");
Console.WriteLine();
water += 25;
}
}
SinFluxx
SinFluxx10mo ago
How do you know .drink() isn't getting called but none of the criteria of your if conditions are met? you should debug and walk through it step-by-step to see what the values are
Want results from more Discord servers?
Add your server