php – correct use of an interface if two different classes are valid as parameters?

I wrote a small tournament platform in one of my projects, but dealing with participants is a bit chaotic and I want to clean it up.

In my case, a tournament can have participants, but either a user or a team can log in to become a participant. A participant now has a user ID or team ID in the database. Depending on which one is filled in, I determine whether a user is linked to the participant or whether it is a team.

I rewritten the registration part of my tournament model to accept both a user and a team as parameters via an interface and wondered if this was the right way to go.

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);
    }
}

With this set, I can register a user or a team, do a little review and, if successful, add them as a participant to the tournament.

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 use the interface?

Views – How to create a listing page with content without using the user interface

I am currently trying to create a Drupal 8 site that displays a list of actors with their picture, description and rating. I've already done this myself with the Drupal user interface, but I want to do the same programmatically. I created the content types and added some content. Now I have to list this content on a list page. If anyone can help me create a custom module and how I can do this task entirely with coding.

Which graphical user interface should be used to move files with Python

I'm interested in starting a Python project that processes files and interacts with SQLite databases. The idea is that the user can select a file on his computer via a graphical interface and move it to the predefined folder in the program and save the path in a database so that it can be restored later. Which library should I use to develop this program? And is it possible to display PDFs after moving?

java – Anonymous class and interface that returns a list

I have a main line that calls the method genericQueryFromTablethat return a list of objects that are modified by an interface ResultSettable. Foo1, Foo2, Foo3 have the same data, only the implementation of the interface is different. Everything works fine, but I would like to revise it.

Is there a way, perhaps through an anonymous class, not to create three different classes? Maybe only one would be enough? (It would be nice not to add any new parameters in setObjectFromResulSet as "int1", "st_b" etc.). Maybe I can pass the implementation of as a parameter ResultSettable.

public interface ResultSettable {
    public abstract  void setObjectFromResulSet(ResultSet rs) throws Exception;
}

public class Foo1 implements ResultSettable {
    int a;
    String b;

    @Override
    public  void setObjectFromResulSet(ResultSet rs) throws Exception {
        a = rs.getInt("int1");
        b = rs.getString("st_b");
    }   
}

public class Foo2 implements ResultSettable {
    int a;
    String b;

    @Override
    public  void setObjectFromResulSet(ResultSet rs) throws Exception {
        a = rs.getInt("int_one");
        b = rs.getString("string_2");
    }   
}

//public class Foo3........

public  List genericQueryFromTable(Class t) throws Exception {
    List lis = new ArrayList();
    //...
    while (rs.next())
    {
        T riep = t.newInstance();
        riep.setObjectFromResulSet(rs);
        lis.add(riep);
    }
    return lis; 
}

I tried to create an abstract class Foothat implements ResultSettablethis way the parameter a and bwill be visible from the method setObjectFromResulSet and I won't have to create new interfaces. But I still can't come to a solution, maybe because setObjectFromResulSet Treat a list, not just an object.

public static void main(String() args) throws Exception {
    //old way:
    List foo1 = genericQueryFromTable(Foo1.class);
    List foo2 = genericQueryFromTable(Foo2.class);
    List foo3 = genericQueryFromTable(Foo3.class);

    //I was thinking to create something like this, where Foo is an abstract class
    List fooOne = genericQueryFromTable(Foo.class, new Foo {   
        @Override
        public  void setObjectFromResulSet(ResultSet rs) throws Exception {
            a = rs.getInt("int1");
            b = rs.getString("st_b");
        }   
    });
    List fooTwo = genericQueryFromTable(Foo.class, new Foo {   
        @Override
        public  void setObjectFromResulSet(ResultSet rs) throws Exception {
            a = rs.getInt("int_one");
            b = rs.getString("string_2");
        }   
    });
    //fooThree...

}

Info visualization – Guidelines for creating connections between different areas of a user interface

Previous discussion What is an intuitive user interface for connecting UI elements?

We have a web application called Genome Browser and we want to connect different areas of the genome. Since this is a kind of application-specific context, let's imagine a more general idea. Suppose you have two different diagrams and you want to connect points between them

So we can mock that

Enter the image description here

Now what if instead of just one bar chart at the top and bottom, we have two at the top and two at the bottom, the top two linked by their genome region and the bottom two by their genome region. So if we want to make connections between them, there are many cross-sectional elements

Enter the image description here

At this point, the user interface seems pretty messy. There are also other concerns such as

  • The connecting lines have to be drawn in an overlay, and this really limits the interaction with it, as overlays in HTML really mess up your event handling: you have to insert pointer events: none in the overlay to click underlay and can possibly be deactivated, to interact with the overlay. However, this requires manual switching
  • What if we only render the connection lines regardless of the diagrams above and below because we may only care about the connections and the pattern they create more than the actual bar diagrams. In this case, we can only render to a middle section instead of an overlay, but it gets a little confusing what "status" this now has in the app. How can you turn it on and off when it is separated from the lines in the app? above and below?

These are just a few concerns. The overlay often leads to at least visual chaos and conceptual confusion, although in some cases it can also be helpful. Are there guidelines or similar user interfaces in other apps that have this type of concern?

Docker Bridge -> Route over a certain interface

I have two interfaces on the host. Docker is installed and br0 is forwarded via the standard interface (eth0). I added a second Docker bridge (br-alt) and I want it to be routed over the secondary connection (eth1).

How do I make sure the br-alt-Pods network is routed through eth1?

I have the following (relevant parts of the inspection) for my bridge, and the pod I have is still routing via eth0

"IPAM": {
    "Driver": "default",
    "Options": {},
    "Config": (
        {
            "Subnet": "172.16.32.0/24",
            "IPRange": "172.16.32.192/26",
            "AuxiliaryAddresses": {
                "hostint": "172.16.32.5",
                "router": "172.16.32.1"
            }
        }
    )
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
    "Network": ""
},
"Options": {
    "com.docker.network.bridge.name": "eth1"

What is the terminology, the name of the user interface for the read-only field value?

What is the terminology of these UI elements in this screenshot?

  • John Doe
  • https://www.facebook.com/john.doe
  • Principal: john.doe@gmail.com

These UI elements are read-only field values, these values ​​can be edited by Update (Modifier in French) link button.

I'm looking for good terminology to use in search engines to find UX design examples.

Enter the image description here

ionic – user interface for contact search blocks?

Environment:

  • Ionic v3
  • cordova-plugin-contacts@3.0.1
  • iOS 13.3.1

I have a problem. I added a simulator with 1000 contacts. When I try to search the contacts using Cordova plugin contacts, the user interface crashes when retrieving them.

I get the following message in the xcode console. "Get 250 contacts in bluk"

According to GitHub, the plugin is out of date and I don't know if it's a problem with the plugin source.

gui – user interface of game database editor like Age of Epires & # 39; AGE

Age of Empires had this powerful AGE (Advanced Genie Editor) tool that allows players to easily change game data. You could view and play with all of the game's databases using this tool to create your own mods in a fairly simple way, which presumably was also used by the developers themselves to create their data.

Screenshot of the AGE tool

I was wondering how I could implement a similar editing interface for my game database.

Are there any tricks that Godot, Unity and Unreal users use to compose their data? I feel like I've missed something because no popular engine seems to support what I'm looking for right away.

If I can't do it in the engine, how am I supposed to make such a tool myself?

User Interface – How do I approach the user interface for this one-page WordPress app?

I am developing a single page app that I would like to integrate into WordPress at some point. I have a picture of what I want to achieve and I want to achieve it in the most efficient and modern way I take.

What asks me for help is that it is not cut and dry like a standard web format. I have floating boxes on my page that all represent an object that will fill my backend. I would like to divide my page into three sections:

Section 1: 4-6 free-floating symmetrical boxes in this section of the page

Section 2: 12-20 floating boxes in this part of the page

Section 3: 1 large section that alternates between sections and shows elements like the previous sections of the page, but with different amounts of encapsulated elements.

It is expected that these are also suitable for mobile devices.

View post on imgur.com