Redoxi
Redoxi
Explore posts from servers
CC#
Created by Redoxi on 10/13/2023 in #help
❔ How to sync a git branch on my laptop?
Hey, i made a branch in a repository with my pc, now i need to edit some files but i don't have that branch on my laptop. Is there a way to clone the branch so i can use it on my laptop and be able to sync it on my pc when i want to do further changes later?
19 replies
CC#
Created by Redoxi on 11/2/2022 in #help
Why does this not work? [Answered]
Hey, pretty new to coding and trying some things out, someone knows why it says that my var "randomNumber" is not in the context?
using System;

namespace Awesome_Program
{
class Program
{
static void Main(string[] args)
{
Typewriter("Hello... Wizard!");
}

public static int NumberGen()
{
Random numberGen = new Random();
int number = numberGen.Next(50,300);
}

public static void Typewriter(string word)
{
for (int i = 0; i < word.Length; i++)
{
Console.Write(word[i]);
int randomNumber = NumberGen();
System.Threading.Thread.Sleep(randomNumber);
}
}
}
}
using System;

namespace Awesome_Program
{
class Program
{
static void Main(string[] args)
{
Typewriter("Hello... Wizard!");
}

public static int NumberGen()
{
Random numberGen = new Random();
int number = numberGen.Next(50,300);
}

public static void Typewriter(string word)
{
for (int i = 0; i < word.Length; i++)
{
Console.Write(word[i]);
int randomNumber = NumberGen();
System.Threading.Thread.Sleep(randomNumber);
}
}
}
}
10 replies
CC#
Created by Redoxi on 11/2/2022 in #help
Is this Loop and Method right?
Hey, i just did Brackeys C# beginner course and i just wanted to try out some things. I did a Wizard class and i wanna do a Method where the class can "train" to get spellslots and there is a risky or normal way, while he can only do this train when the spellslots var is over 0. Is this code here right? Or should i change something.
public void SpellSlotsTrain()
{
Console.WriteLine("Do you want to take the Risky or the Normal way?");
Console.WriteLine("Risky: 80% Rate to lose 1 Spell Slots, 20% To Gain 3");
Console.WriteLine("Normal: 80% Rate to gain 1 Spell Slot, 20% lose 1");
string choise = Console.ReadLine();

int number;
Random numberGen = new Random();
number = numberGen.Next(1, 101);

while (spellSlots > 0)
{
if (choise == "Risky")
{
if (number > 80)
{
spellSlots += 3;
break;
} else if (number < 80)
{
spellSlots -= 1;
break;
}
}
else if (choise == "Normal")
{
if (number > 80)
{
spellSlots -= 1;
break;
} else if (number < 80)
{
spellSlots += 1;
break;
}
}
else
{
Console.WriteLine("Wrong Input, Please write Risky or Normal.");
}
}
}
public void SpellSlotsTrain()
{
Console.WriteLine("Do you want to take the Risky or the Normal way?");
Console.WriteLine("Risky: 80% Rate to lose 1 Spell Slots, 20% To Gain 3");
Console.WriteLine("Normal: 80% Rate to gain 1 Spell Slot, 20% lose 1");
string choise = Console.ReadLine();

int number;
Random numberGen = new Random();
number = numberGen.Next(1, 101);

while (spellSlots > 0)
{
if (choise == "Risky")
{
if (number > 80)
{
spellSlots += 3;
break;
} else if (number < 80)
{
spellSlots -= 1;
break;
}
}
else if (choise == "Normal")
{
if (number > 80)
{
spellSlots -= 1;
break;
} else if (number < 80)
{
spellSlots += 1;
break;
}
}
else
{
Console.WriteLine("Wrong Input, Please write Risky or Normal.");
}
}
}
34 replies