Skip to content

Feature: Colocando minha solução#7

Open
AnthonyMRodrigues wants to merge 1 commit into
PHPRio:masterfrom
AnthonyMRodrigues:solucaoMedia
Open

Feature: Colocando minha solução#7
AnthonyMRodrigues wants to merge 1 commit into
PHPRio:masterfrom
AnthonyMRodrigues:solucaoMedia

Conversation

@AnthonyMRodrigues

Copy link
Copy Markdown

Solução Media


$firstValue = $argv[1];
$secondValue = $argv[2];
if ((is_null($firstValue) || $firstValue > 10.0) || (is_null($secondValue) || $secondValue > 10.0)) {

@vitormattos vitormattos Oct 19, 2018

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isto vai dar ruim se os valores informados forem string. Que tal usar filter_var com FILTER_VALIDATE_FLOAT ou algo em conjunto com FILTER_VALIDATE_INT?

Como a função tá forçando tipagem, isto também pode dar bem ruim se não for float, não?!

@@ -0,0 +1,37 @@
<?php
/**
* Created by PhpStorm.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O código todo tá com uma tabulação a mais no começo

return;
}

echo "Media = " . media($firstValue, $secondValue, 3.5, 7.5) . "\n"; No newline at end of file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Atende por não termos ainda testes automatizados, mas na especificação tá em uppercase.

@vitormattos vitormattos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Algumas dicas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants