#PHP exercise

274 messages · Page 1 of 1 (latest)

boreal glacier
#

Some of PHP's documentation has been translated to other languages apart from English, so you might find another language in there that's easier to understand.

earnest stag
#

Sharing code blocks (instead of screenshots) will increase your chance of getting help (and is a part of community etiquette, which is also recommended in error messages). Thanks for your understanding!

#

You enclose the beginning and end of the code with triple backticks (`).
Note, use backticks (`), not single quotation marks (').

For example, you can type the following:
The ``` must be on their own line.

```
not wrapped
```

Discord will render that as:

wrapped!

Happy coding!

turbid surge
#

Can you share your code in a codeblock?

turbid surge
#

jun-kazama told you how.

cinder ravineBOT
turbid surge
#

@near knoll Does that help?

turbid surge
#

That doesn't look like valid code

#

Are you completely new to programming?

near knoll
#

I'll a re-write coding

turbid surge
#

Images are harder for me to read. Text is easier.

near knoll
#
class Lasagna
{
public function expectedCookTime()
{
    return 40;
}

public function remainingCookTime($elapsed_minutes)
{
    return 20;
        
}

public function totalPreparationTime($layers_to_prep)
{
    return 10;

    return ;       
 }
turbid surge
#

What's the last return line do in the last function?
What tests fail? What's the output (as a codeblock)?

near knoll
#

disconsider last return;

#

the test fail question are the screenshot because the reason

near knoll
turbid surge
#

You're describing the failure in vague terms. The exact test details would help

cinder ravineBOT
#

Asking questions well increases your chance of getting help. Learn how to write good support requests in this article: http://bit.ly/howto-ask

near knoll
#

the error are i can't return for interger value
the question talsks are returns how many minutes the lasagna must be in the oven when it is 30 minutes in the oven already

the function ($layers_to_prep, $elapsed_minutes)

you can understand ?

turbid surge
#

Can you copy/paste the full test output?

#

Run test -> Test Failure -> Select All -> Copy -> Discord -> ``` + paste + ```

near knoll
turbid surge
#

No thank you. You can copy/paste the test output here

#

That way anyone can help out, not just me

near knoll
#

basically i have a return many minutes remaining

#

but interger value

#

LasagnaTest::testAnotherRemainingCookTime
Failed asserting that 20 matches expected 10.

/mnt/exercism-iteration/LasagnaTest.php:51

turbid surge
#

Can you also copy paste the test "CODE RUN"?

near knoll
turbid surge
#

Ideally in a codeblock, but... 🤷‍♂️

#

​​1. Do you understand what the test is doing?
2. Do you understand what the test is expecting and why?
3. Do you understand what your code returns and how it differs?
4. Do you understand why your code is returning what it returns?

​​1. Você entende o que o teste está fazendo?
2. Você entende o que o teste espera e por quê?
3. Você entende o que seu código retorna e como ele difere?
4. Você entende por que seu código está retornando o que retorna?

near knoll
#
$lasagna = new Lasagna();
$this->assertEquals(10, $lasagna->remainingCookTime(30));

turbid surge
#

Do you understand what the test is doing? <> Você entende o que o teste está fazendo?

near knoll
turbid surge
#

Do you understand what this test expects the result to be, and why? Você entende o que este teste espera que seja o resultado e por quê?

near knoll
#

yes , sim entendo
after 30 minutes the answer its 10 because the total time are a definied in the top of the program = 40
but i can't return this value as a interger

turbid surge
#

Why not?

near knoll
#

i don't know answer

#

i have no idea
the logical i understand

turbid surge
#

What is the logic?

near knoll
#

i have 2 parameters layers and elapsed
layers are defined before its a 10
and the previous question the elapsedtime this is equal 20

turbid surge
#

The number of layers here does not matter

#

The function needs to determine how many minutes remain based on the elapsed minutes.

#

If 30 minutes elapsed, how many minutes remain?

#

Each unit test is independent from all the other unit tests

near knoll
#

but total cookie time parameter aren't in this function

boreal glacier
turbid surge
#

How do you get 10? Can you explain the logic/steps?

#

@near knoll ?

near knoll
#

@turbid surge be patient kkkk I'm a learning

turbid surge
#

Can you show you to get 10 using math?

#

Or even algebra?

near knoll
turbid surge
#

You need math to solve this task, yes

near knoll
#

yes, but you only make asks, not expalin how solve this task

#

some explain me solve this task

#

?

turbid surge
#

Yes. I know how to solve this task. I am helping you figure out how to solve this task.

#

total its 40
but already 30 minutes in the oven
remaining 10 to 40
Can you show this using math?

near knoll
near knoll
turbid surge
#

No. Each test is completely separate.

#

How you show how to get 10 using math?

near knoll
#

again
total cookie time = 40
but he's in the oven 30 minutes
remain 10 minutes to 40 total time

#

this is my think

turbid surge
#

Can you do that using math operators? Plus minus times divide? + = * /?

near knoll
#

operator -

turbid surge
#

What's the full equation?

near knoll
#

40-30

turbid surge
#

Awesome. That's getting somewhere.

#

What if 30 is $elapsed_minutes ?

near knoll
turbid surge
#

How many minutes remains after $elapsed_minutes time? Using math?

turbid surge
#

If 30 minutes elapsed, how much time is left (using math)?

#

If 30 minutes elapsed, how many minutes remain?
=> 40 - 30
If $elapsed_minutes minutes elapsed, how many minutes remain?
=> ???

#

See the pattern?

near knoll
# turbid surge See the pattern?

wait
i need the answer low
i thinking know the wrong way

i dont make any operation in this code
i put on return the value direct, dont math operator

#

return = 10

turbid surge
#

You need math since the elapsed time can change

near knoll
#

its true

#

?

#

but i nedd define the variable math before?

#

need*

turbid surge
#

The variable is passed into the function. It is $elapsed_minutes. The value of that variable changes depending how the function is called.

#
new Lasagna()->remainingCookTime(10);
new Lasagna()->remainingCookTime(20);
new Lasagna()->remainingCookTime(30);
near knoll
#

and after the parameter with a math cointained a variable

turbid surge
#

Yes

near knoll
#

now i understand better

turbid surge
#

$elapsed_minutes

near knoll
#

i'm

#

finally kkkk

turbid surge
#

ElapsedTime and $elapsed_minutes are not the same thing 🙂

near knoll
#

you're a really patient with me

turbid surge
#

I try 😄 Thank you

near knoll
turbid surge
near knoll
#

ignore

#

i'm tried to pass the variable for math

turbid surge
#

Did it work?
If not, can you share your code and the test output?

near knoll
#

yes

#

i'm trying it

#

public function totalElapsedTime($layers_to_prep, $elapsed_minutes)
    {
          new Lasagna()->remainingCookTime(10);
          new Lasagna()->remainingCookTime(20);  
          new Lasagna()->remainingCookTime(30);      
          return $elapsed_minutes(40) - $remaingCookTime(30);

    }
#

$lasagna = new Lasagna();
$this->assertEquals(40, $lasagna->expectedCookTime());

``````´
turbid surge
#

What is the test failure message?

near knoll
#

one moment

near knoll
earnest stag
#

Excuse me for interrupting. I translated how to create code blocks into Portuguese.

#

Compartilhar blocos de código (em vez de capturas de tela) aumentará suas chances de obter ajuda (e faz parte da etiqueta da comunidade, que também é recomendada em mensagens de erro).

Você envolve o início e o fim do código com três acentos graves (`).
Observação: use acentos graves (`), não aspas simples (').

Por exemplo, você pode digitar o seguinte:
O ``` deve estar em sua própria linha.

```
não envolvido
```

O Discord irá renderizar isso como:

envolvido!

Feliz codificação!

turbid surge
#

What is the totalElapsedTime function supposed to do?

near knoll
turbid surge
#

Sleep is important!

near knoll
turbid surge
#

It doesn't say "30" anywhere there

#

Nor do I see "remain" anywhere there

near knoll
#

sorry

turbid surge
#

Step one: understand what the function is supposed to do

#

You can't solve without knowing what you are solving

near knoll
#

public function totalElapsedTime($layers_to_prep, $elapsed_minutes)
    {
          new Lasagna()->remainingCookTime(10);
          new Lasagna()->remainingCookTime(20);  
          new Lasagna()->remainingCookTime(30);      
          return $elapsed_minutes(40) - $remaingCookTime(30);

    }

yes the function need total time - remain cooking time consider stay 30 minutes already, on this case how many remaining minutes need return
#

Yes, you have to calculate how many minutes are left considering that there are already 30 minutes in the oven

turbid surge
#

No. 30 is not part of the problem. There might be 5 minutes or 15 or 30 in the oven.

#

It varies.

#

It asks you to compute the total elapsed time. What math would you use to calculate elapsed time?

near knoll
#

no idea

turbid surge
#

Did you read the instructions? Did you understand them?

near knoll
#

because there would have to be the total recipe time minus mathematical operation, the remaining time
I couldn't think straight

#

yes

#

i'm read again

#

now it's clear

#

the function have a 2 arguments
number of layers and minutes in the oven , on this case this number 30

turbid surge
#

👍

#

It could be 20 or 40 too

near knoll
#

yes because the function need rreturn total time cooking lasagna

#

would be sum the prepare minutes + cookink time minutes

near knoll
#

the problem in the language spoke are a solve
but i transformer this in a code

near knoll
near knoll
#

Teamates
We've been chatting here with you for 2 days and so far I can't
please give me the solution and explain how to do it, I want to move on to the next task

turbid surge
#

How did you solve the first function? Can you do something similar with this one?

#

Write it as math and use variables where numbers go

near knoll
#
return 40;

my first function and the exercism is allright

turbid surge
#

Sorry. What about the second function?

near knoll
near knoll
#

the first function solve this

turbid surge
#

Did you solve the second function?

near knoll
#

yes

#

the same way

turbid surge
#

Using a variable?

near knoll
#

but the value 20

near knoll
turbid surge
#

You're second function is return 20?

near knoll
#

 public function remainingCookTime($elapsed_minutes)
    {
        return 20;
            
    }
near knoll
turbid surge
#

That passes the test? That doesn't look right.

near knoll
turbid surge
#

Do you understand what a variable is?

#

Do you know how to use them in a function?

near knoll
#

ask me again ?

turbid surge
#

Do you understand what a variable is?

near knoll
#

yes

#

You do many asks isaac
troool

#

kkkkk

near knoll
turbid surge
#

What should remainingCookTime(10) return?

near knoll
#

here

#

i put

#

10 its a layers i put

turbid surge
#

If 10 minutes elapsed, then 20 is the wrong result

near knoll
#

10 its a layers_to_prep

near knoll
turbid surge
#
 public function remainingCookTime($elapsed_minutes)
    {
        return 20;
            
    }
#

10 is $elapsed_minutes

#

Functions are supposed to return a value which changes based on the inputs

near knoll
#

if elapsed = 10 because return = 20
stiill i can't understand

turbid surge
#

If elapsed = 10, then what should it return?

#

Are you familiar with algebra?

near knoll
#

@turbid surge in the code show elapsed = 20
why you say elapsed = 10?
i'm not understand the reason elapsed 10 value

turbid surge
#

Elapsed is a variable. It can hold any value. It's value is set when the function is called.

remainingCookTime(5) --> elapsed time is 5
remainingCookTime(30) --> elapsed time is 30
remainingCookTime(13) --> elapsed time is 13
near knoll
#

just in return i put the variable elapsed it's correct?

turbid surge
#

What should the remaining time be if elapsed is 10?

near knoll
#

30

#

10 + 30

#

40

turbid surge
#

If remaining time is y,
y = ?

near knoll
#

not understand

turbid surge
#

Remaining time is equal to ...?

#

What steps do I take to compute remaining time?

near knoll
#

isaac i want to finished this tasks

#

this night

#

do you have an solution for this code?

#

i answer wait a moment

turbid surge
#

Yes. But you won't learn by copy pasting a solution

near knoll
turbid surge
#

What's the purpose of doing the exercise, if not learning?

near knoll
turbid surge
#

If I know the elapsed time, how can I find out the remaining time? What do I need to do?

near knoll
turbid surge
#

Oooh! Very good

#

That almost looks like code!

#
 expectedcookietime() - elapsed minutes
near knoll
#

but i haven't anyone in the code variabel cookie time only a function

turbid surge
#

Which function? What's the function name?

near knoll
near knoll
#

->

turbid surge
#

You said "first function"

#

What is the first function?

near knoll
#

expectedcookietime i mentioned kkkk
showing the screenshoot kkkkkk

#

trool

turbid surge
#

If you call me a troll, I could always ban you for being unappreciative of my time 😛

#

There is no function expectedcookietime() in your code. Look closer.

near knoll
#

i know it's a function, not a variable

turbid surge
#

What's the exact function name?

near knoll
#

I thought I needed the expected cooking time variable

near knoll
turbid surge
#

So

 expectedCookTime() - elapsed minutes
#

And what's the exact spelling of the elapsed minutes?

near knoll
turbid surge
#

So that give this, right?

 expectedCookTime() -  $elapsed_minutes
#

And what is your function supposed to do with that value?

near knoll
#

but i think need pass as the parameter using ->

#

expectedCookTime()->$elapsed_minutes

turbid surge
#

For the remainingCookTime()?

#

This gives the remaining cook time:

 expectedCookTime() -  $elapsed_minutes
turbid surge
#

Do you understand what this code does?

 expectedCookTime() -  $elapsed_minutes
near knoll
#

seems like

expectedCookTime()->$elapsed_minutes
return $elapsed_minutes
#

firts transformer or pass the function as a variable
after called the variable

near knoll
#

Hi Morning
Some can help me this a task

near knoll
#

someone can help me please

#

i need

#

@turbid surge you are here?

#

 public function totalElapsedTime($layers_to_prep, $elapsed_minutes)
    {
             
         expectedCookTime()->$elapsed_minutes;
         return $elapsed_minutes;

    }
earnest stag
#

I don't understand PHP, so I can't help you, but what are you trying to make the computer calculate in this function?

turbid surge
#

You might want to read up on the basics of functions. Or the basics of programming.

near knoll
turbid surge
#

I've helped as much as I can. You seem to be missing some fundamental basics. You need to learn those first and I can't teach you all the basics.

near knoll
#

I can already do some basic crud alone, but here in this exercise statement I'm stuck and alone I can't go anywhere in this code

turbid surge
#

You're unable to do this exercise because you're missing basic concepts.

#

Do you want to solve the exercises or do you want to learn programming?

near knoll
turbid surge
near knoll
#

now i'm stay in the php doc site

turbid surge
near knoll
turbid surge
#

You seem to be having trouble with the concept of functions and parameters and parameterized return values.