© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2mo ago•
86 replies
Cocaine bear

hi im back with another assignment and im kinda stumped

beginner
🎯 Task 1: Attack an Enemy Until Defeated
The enemy starts with 10 health points.

Repeatedly attack the enemy until Its health is 0 or less (enemy defeated)

Each attack deals random damage between 3 and 6 (including)


After each attack, print the damage dealt and the enemy’s remaining health.


Once the enemy’s health drops to 0 or less, print “Enemy is defeated!”.


Use a while loop to control the attacks.

To create a random number, use this line of code:
int damage = new Random().Next(x,y);
where x and y define the range of random numbers from x to y (excluding y)
For example: new Random().Next(3,7);
will generate a random number between 3 and 6 (7 excluded).
this is my specific instructions on what i need to do i make random damage values and at the same time i gotta do a while loop which i will be honest i kind of forgot how to do this is what i have as of now which isnt much funny thing is that i helped a buddy do it in real time but when im doing it myself i somehow forget everything
image.png
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements
Next page

Similar Threads

✅ hi im experimenting with websocketsservers and clients.
C#CC# / help
4y ago
✅ Im kinda new to csharp
C#CC# / help
3y ago
Im new to C# and im kinda stuck here. Please help
C#CC# / help
2y ago
✅ help with assignment
C#CC# / help
2y ago