php: correct use of an interface when two different classes are valid as parameter?

In one of my projects I wrote a small tournament platform, but the way I handle the participants is a bit messy and I want to clean this up.

So in my case, a Tournament can have participants, but a User or a Team can register to become participants. A participant now has a user_id or team_id in the database, and depending on which one is full, I determine if a user is linked to the participant or if it is a team.

I rewrote the registration part of my Tournament model to accept a User or a Team as parameter through the am interface and I was wondering if this is the correct way to do it.

ICandidate.php

interface ICandidate
{
    public function getName();
    public function hasCorrectGamesSet($tournamentGame);
}

User.php

class User implements ICandidate
{
    private $game;

    public function __construct($game)
    {
        $this->game = $game;
    }

    public function getName()
    {
        return 'Username';
    }

    public function hasCorrectGamesSet($tournamentGame)
    {
        if($this->game != $tournamentGame){
            throw new Exception('Incorrect name');
        };

        return true;
    }
}

Team.php

class Team implements ICandidate
{
    private $users;

    public function __construct($users)
    {
        $this->users = $users;
    }

    public function getName()
    {
        return 'Teamname';
    }

    public function hasCorrectGamesSet($tournamentGame)
    {
        foreach($this->users as $user){
            $user->hasCorrectGamesSet($tournamentGame);
        }
    }
}

Participant.php

class Participant
{
    private $name;
    private $class;

    public function setName($name)
    {
        $this->name = $name;
    }

    public function setClass($class)
    {
        $this->class = $class;
    }
}

Tournament.php

class Tournament
{
    private $participants;
    private $game;

    public function __construct($game)
    {
        $this->game = $game;
    }

    public function signUp(ICandidate $candidate)
    {
        $candidate->hasCorrectGamesSet($this->game);

        $participant = new Participant();
        $participant->setName($candidate->getName());
        $participant->setClass(get_class($candidate));

        $this->participants() = $participant;
    }

    public function getParticipants()
    {
        var_dump($this->participants);
    }
}

So with this set, I can register a User or a Team, do a little checking and, if that happens, add them as tournament participants.

Logic

$tournament = new Tournament('fifa');

$user1 = new User('fifa');
$user2 = new User('fifa');
$user3 = new User('fifa');
$user4 = new User('fifa');

$team = new Team(($user2, $user3, $user4));

$tournament->signUp($user1);
$tournament->signUp($team);

$tournament->getParticipants();

Is this a correct way to implement this and make use of the interface?

pr.probability – Minimizing $ int lambda ({ rm d} y) frac { left | g (y) – frac {p (y)} c lambda g right | ^ 2} {r ((i, x), y)} $ with respect to the discrete parameter $ i $

Leave $ I subseteq mathbb N $ be finite and not empty, $ (E, E math, lambda) $ be a $ sigma $-finite space measure, $$ lambda f: = int f : { rm d} lambda $$ for $ lambda $integrable $ f: E to mathbb R $, $ p: E to (0, infty) $ to be $ mathcal E $-measurable with $ c: = lambda p in (0, infty) $, $ r: (I times E) times E to (0, infty) $ to be $ (2 ^ I otimes mathcal E) otimes mathcal E $-measurable with $ lambda r ((i, x), ; cdot πŸ˜‰ = 1 $ for all $ (i, x) in I times E $ Y $ g: E to (0, infty) $ to be $ mathcal E $-measurable.

How can I calculate for what $ i in I $ the amount $$ sigma_i: = int lambda ({ rm d} y) frac { displaystyle left | g (y) – frac {p (y)} c lambda g right | ^ 2} {r ((i, x), y)} $$ is minimal (if there is more than a minimum $ i $, I want to choose the smallest)? I am no interested in the value of $ sigma_i $.

At the moment, I am estimating each $ sigma_i $ using the Monte Carlo integration (sampling of $ r ((i, x), ; cdot πŸ˜‰ $ possible) and computing the smallest index $ i $ whose corresponding estimate of $ sigma_i $ However, this is error prone (since the estimation of $ sigma_i $ might not be close enough to $ sigma_i $) and extremely slow. The latter is my real problem as I need to solve this problem by $ approx1e5 $ different $ g $ inside a range loop $ ge1e5 $.

So is there a smarter solution to this problem?

inequality – Equations and inequalities with a parameter!

Thanks for contributing with a response to Mathematics Stack Exchange!

  • Please make sure answer the question. Please provide details and share your research!

But avoid

  • Ask for help, clarification or respond to other answers.
  • Make statements based on opinion; back them up with references or personal experience.

Use MathJax to format equations. MathJax reference.

For more information, check out our tips on how to write great answers.

collection – Array as query parameter in Magento 1.9 custom rest API

I have created a custom module for the guest user rest API, to get a custom product collection, but I am having trouble passing the array in the query parameter, to get some collection values ​​in response.

You are treating the array parameter as a string.

Suppose I am passing categories name (name can contains some sysmbols and space as well)

URL be like:

http://127.0.0.1/magento/api/rest/similar-products/categories(test%20category,categroy2)

http://127.0.0.1/magento/api/rest/similar-products/categories(0)=category1&categories(1)=category%20new

But all these methods don't work for me.

pass JavaScript button parameter from JavaScript to Google Apps Script

I tried this tutorial, but it was not written for v8, and the logger and javascript parameter passing between html and script don't work. https://www.youtube.com/watch?v=RRQvySxaCW0
I learned how to use the older rhino version of Google's app script, but I can't get variables to pass from HTML to script.

In the second part, they give an example of using javascript to pass the username to the script.
Inside the HTML file I have this:

var usname = document.getElementById("username").value;
    google.script.run.userClicked(usname);

and in the script I have:

function userClicked(uname){
  Logger.log(uname + " clicked");
}

But I do not receive any data in uname. It says "undefined click" on the record. Any suggestions for this to work?

azure sql database – How to solve parameter detection problem in query with operator & # 39; in & # 39;

I have a parameter detection problem in this Azure SQL Server consult with in operator:

    Select Col1, Col2, ..., Coln from T1 Join T2 
    On T1.Id = T2.T1Id
    Where T2.Col2 in ('uniqueIdentifier_1','uniqueIdentifier_2',..., 'uniqueIdentifier_m')

I have around 30-40 unique identifiers in the where clause. And I can't replace them because they are primary keys of another table in another Azure SQL Database. As you can see there are a variety of different unique identifiers and it is difficult to adjust.
Could you guide me to solve a parameter sniffing problem?

c – Returns a dynamically created character array of the function as parameter

I am trying to return a dynamically created character array of the function. But the returned array has no characters that I created based on. I am using this code.

bool test(char** myCharArray)
{
   char *response = malloc(2);
   response(0) = 'A';
   response(1) = 'B';

   *myCharArray = response;
   return true;
}

int main()
{
  char* testArray;

  bool result = test(&testArray);

  char c1 = testArray(0);
  char c2 = testArray(1);

  // c1 is not equal to 'A'
  // c2 is not equal to 'B'

}

What is the problem?

Magento 1.9: The second parameter of the pagination of the product list is missing (/category1/category2.html)

I created a custom module to handle filters by 2 categories, like: https://example.com/clearance/phones.html.

Clearance and phones are both categories.

The router is working properly. I am filtering the product collection by "Clearance" AND "Telephones" categories by extending the _getProductCollection method of Mage_Catalog_Block_Product_List, and it is also working.

But there is something wrong with pagination.

If I visit the URL above, the pagination links look like this:

Page 1 – https://example.com/clearance.html?p=1

Page 2 – https://example.com/clearance.html?p=2

Page 3 – https://example.com/clearance.html?p=3 (And so on)

Why is the second parameter (phone category) missing?

PHP warning: in_array () expects parameter 2 to be an array, given string

I can not solve. my record keeps filling
/includes/functions.php on line 700

line 700

if ( $cam->$item == '' . $value . '' ) {
Code (marked):

online sharepoint: how does OverrideViewXml parameter work with ViewXml in RenderListDataAsStream in rest API?

I am working to get data from SharePoint list using RenderListDataAsStream endpoint.
What I'm doing is getting all the views defined for the list first and displaying them in a dropdown in the user interface and then when the user selects the view

  • I get the ListViewXML for that view
  • Create a custom filter query similar to ...

and then pass that ListViewXML as ViewXML and custom filter like OverrideViewXml in the body parameters for the RenderListDataAsStream break call.

From here it says that OverrideViewXml is for

Specifies the override XML to be combined with View CAML. It only applies to the Query / Where part of the CAML view.

I want to know how exactly OverrideViewXml works in conjunction with ViewXml. When I specify ViewXML, the OverrideViewXml query is ignored or doesn't work. When I specify only OverrideViewXml and not ViewXml, the OverrideViewXml query works. Right now for me, the results don't come with any combination (either "AND" or "OR") of OverrideViewXml with ViewXML.

For break calls I am using PNP JS library (2.0.3) and the solution is in SPFX