#C# Lucian's Luscious Lasagna Learning Task
74 messages Β· Page 1 of 1 (latest)
Increase your chance of getting help and look like a pro by sharing codeblocks not images. For example, you can type the following. Note, the ``` must be on their own line.
```
for number in range(10):
total += number;
```
Discord will render that as so:
for number in range(10):
total += number;
Click here to learn more about codeblocks: https://exercism.org/docs/community/being-a-good-community-member/writing-support-requests and http://bit.ly/howto-ask
class Lasagna
{
// TODO: define the 'ExpectedMinutesInOven()' method
public int ExpectedMinutesInOven(){
return 40;
}
// TODO: define the 'RemainingMinutesInOven()' method
public int RemainingMinutesInOven(int number){
return ExpectedMinutesInOven() - number;
}
// TODO: define the 'PreparationTimeInMinutes()' method
public int PreparationTimeInMinutes(int number){
return number * 2;
}
// TODO: define the 'ElapsedTimeInMinutes()' method
public int ElapsedTimeInMinutes(int layers, int oven){
int number = PreparationTimeInMinutes(layers);
int number2 = RemainingMinutesInOven(oven);
return number + number2;
}
}
Code Run:
Assert.Equal(2, new Lasagna().PreparationTimeInMinutes(1));
Test Failure:
Assert.Equal() Failure: Values differ
Expected: 2
Actual: 3
ah got it
Could you kindly edit that code post and change your triple quotes ''' to backticks ```?
yea sorry did it wrong
Figured out codeblocks? Or figured out the exercise?
No worries. Exercism is all about learning π
the exercise
the last one is false
but i pressed on that im stuck but i didnt helped me
so now i need more help haha
the rest is correct
so just the part with the ElapsedTimeInMinutes() method
How do you calculate elapsed time? What goes into figuring out how much time has already passed?
Itβs on in my code above or π
I meant, can you explain it in English
The code fails the tests so it's not doing the right thing π I'm trying to focus on figuring out the right thing.
Okay. I'm waiting.
Uh... in English. Imagine you're in a kitchen making a lasagna and someone asks how much time elapsed. How do you determine that?
Stop thinking about the code. Think about the problem.
i just stop the time or ? π
so i have a timer and check when time is over
first method is 40 min
Hah. You're assuming there'sa timer in the kitchen π
What if the timer was started when the lasagna went into the oven.
You know (1) how many layers the lasagna has and (2) how long it's been in the oven.
Given (1) and (2), how would you tell how long you've been working on the lasagna?
If there are 5 layers and it's been in the oven for 10 minutes ... that's a total of 50 minutes?
So, if there are 5 layers and it's been in the oven for 10 minutes, how much time has passed?
The question isn't how much time is left π
The question is, how long have you been in the kitchen working on the lasagna.
If there are 5 layers and it's been in the oven for 10 minutes, how long have you been in the kitchen?
How did you get that number?
We don't care how much time is left π
I'm not sure why you keep bringing up time left
Uh huh. 2*5 is 10.
yes
So 10 minutes passed? Or 20?
2 min preperation for each layer
and when its 10 min in oven yea then its 20 min
10 +10
Sounds about right. Can you explain that all (how you get time that passed) in a single sentence?
so when i use PreparationTimeInMinutes() i get the time for the preperation
Can you explain, in English, how you'd figure out the time that passed based on the number of layers and how long it's been in the oven?
English first before code π
public int ElapsedTimeInMinutes(int layers, int oven){
return PreparationTimeInMinutes(layers) + ExpectedMinutesInOven() - RemainingMinutesInOven(oven);
}
Can you explain, in English, how you'd figure out the time that passed based on the number of layers and how long it's been in the oven?
it was a logic mistake by me because my english is not so good haha i swap the meaning of remaining and elapsed
π
Note, your code doesn't match what you described above and is more complicated than it ought to be
public int ElapsedTimeInMinutes(int layers, int oven){
return (layers * 2) + oven;
}
That looks much more reasonable.
Always start with English (or your native language) before code.
2 min preperation for each layer and when its 10 min in oven yea then its 20 min
10 +10
This translates pretty well to that code.
You're very welcome
tysm !