-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Number app #15
base: master
Are you sure you want to change the base?
Number app #15
Conversation
Also weird ifs
Also added some ifs
int secondsInput = Convert.ToInt32(Console.ReadLine()); | ||
int hours = secondsInput / 3600; | ||
int secondsRemaining = secondsInput % 3600; | ||
int minutes = secondsRemaining / 60; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Toppen, kul att se lösningen!
Den här koden skulle må bra av några tomma rader, här och var, för läsbarhetens skull.
För kompakt text gör det svårare att hitta specifika stycken.
Prova tex innan och efter Console
-anrop.
Console.WriteLine("Please enter an amount of time in seconds.");
int secondsInput = Convert.ToInt32(Console.ReadLine());
int hours = secondsInput / 3600;
int secondsRemaining = secondsInput % 3600;
int minutes = secondsRemaining / 60;
Console.WriteLine(secondsInput + " seconds equals " + hours + " hours, " + minutes + " minutes and " + secondsRemaining + " seconds."); | ||
Console.WriteLine("Would you like to continue? (y/n)"); | ||
answer = Convert.ToChar(Console.ReadLine()); | ||
if (answer == 'n') { looping = false; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Placera helst logik som följer en if
-sats på en ny rad.
Detta för att du skall kunna skilja på om if
-satsen träffats eller inte i debuggern.
if (answer == 'n')
looping = false;
{ | ||
reversion = String.Concat(reversion, input.Substring(i-1, 1)); | ||
} | ||
Console.WriteLine(reversion); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Denna lösning var påhittig!
Hade jag löst den hade jag använt mig av metoden toCharArray()
på strängen.
Sedan upprättat en array med samma Length
som den ursprungliga och kopierat värdena likt ovan.
Den resulterande strängen kan upprättas med new string(char[])
.
{ | ||
static void Main(string[] args) | ||
{ | ||
Console.WriteLine("Do you want to build a trebuchet? (y/n)"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vem vill inte bygga medeltida belägringsvapen?
Readability.
App written as part of course assignment.
I tried to make it as difficult as possible for the program to throw a tantrum.