C
C#2y ago
Mister0dd

Need help for code to detect last number

Im new to c# and still learning and couldnt find anything useful online and I really need some help Class:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CavalosTrabalho
{
public static class Dias
{
public static int dia = 0;

public static int nextDay()
{
dia = dia + 1;
return dia;
}

public static string dailyEvent(Cavalo cavalo)
{
Random rnd = new Random();
int random = rnd.Next(1, 3);

switch (random)
{
case 1:
cavalo.Velocidade = cavalo.Velocidade + 2;
return "O cavalo sente-se energético e começou a correr sozinho na pista de treino. +2 de Velocidade!";

case 2:
Status Status = Status.doente;
return "O cavalo adoeceu.";

default:
return "Nothing happened";
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CavalosTrabalho
{
public static class Dias
{
public static int dia = 0;

public static int nextDay()
{
dia = dia + 1;
return dia;
}

public static string dailyEvent(Cavalo cavalo)
{
Random rnd = new Random();
int random = rnd.Next(1, 3);

switch (random)
{
case 1:
cavalo.Velocidade = cavalo.Velocidade + 2;
return "O cavalo sente-se energético e começou a correr sozinho na pista de treino. +2 de Velocidade!";

case 2:
Status Status = Status.doente;
return "O cavalo adoeceu.";

default:
return "Nothing happened";
}
}
}
}
Program:
if (Dias.dia % (5))
{
Console.WriteLine(Torneio.race(Player1.Cavalo, Player1));
Console.ReadKey();
}
if (Dias.dia % (5))
{
Console.WriteLine(Torneio.race(Player1.Cavalo, Player1));
Console.ReadKey();
}
I want that, whenever the "dia" (day) last digit is 5, the method "Torneio" gets called. Quick help would be appreciated :) (Any questions about my code, will be whiling to answer and show more details if needed)
3 Replies
Mister0dd
Mister0ddOP2y ago
ps: Dias.dia % (5) was the best that I could find online but didnt work
ero
ero2y ago
if (Dias.dia % 10 == 5) 1 google search https://stackoverflow.com/a/5254833
ero
ero2y ago
pretty much don't even need to click the link
Want results from more Discord servers?
Add your server