Jump to content
Sign in to follow this  
Sim

Can't declare interface, name already in use

Recommended Posts

So: here's the two class files:

<?php

interface Item_Types
{
  
  public function __construct($data = array());
  
    public function getID();
    
  public function getValue();

  public function getName();

  public function getPrice();
  //return results or msg or whatevee you like, if type different from weapon, armour.
    public function useIT();

}

?>
<?php

class Weapon implements Item_Types{
  
  public $desc = "Increases attack power";
  public $itemType = "Weapon";
  public $itemID = null;
  public $name = null;
    public $value = 0;
    public $price = 0;
    public $data = array();
    
    //pass any data needed for item type to be used.
    public function __construct($data = array())
    {
      $this->data = $data;
      $this->itemID = $data['id'];
      $this->name = $data['name'];
      $this->value = $data['value'];
      $this->price = $data['price'];
    }
    
    public function getID(){
        return $this->itemID;
    }
    
  public function getValue(){
        return $this->value;
    }

  public function getName(){
    return $this->name;
  }

  public function getPrice(){
    
  }
  //returns value.
    public function useIT(){
      //was testing to see if could access properties
      global $db, $user;
      
      $user = new user(1, false);
      $user->set("US_money", $user->user->info->US_money + 10000);
      return $this->value;
    }
    
 
}

   include $ItemTypesDir . "ItemTypes.interface.php";
    include $ItemTypesDir . $iType["parentID"] . ".itemType.php";

 

Causes error:

There was an error!

File: /home/simmakew/public_html/GL/modules/installed/itemTypes/Types/ItemTypes.interface.php
Line: 3
Error: Cannot declare interface Item_Types, because the name is already in use
Type: E_RECOVERABLE_ERROR

 

But if I do this:

   //include $ItemTypesDir . "ItemTypes.interface.php";
    include $ItemTypesDir . $iType["parentID"] . ".itemType.php";

Comment the interface out. I get this error

There was an error!

File: /home/simmakew/public_html/GL/modules/installed/itemTypes/Types/Weapon.itemType.php
Line: 3
Error: Interface 'Item_Types' not found
Type: E_RECOVERABLE_ERROR

 

I highly doubt that there is any variable or object named Item_Types. I changed it t to that after I received the error to see if maybe I did declare something "ItemType" before changing, but I don't use _____ in any variables classes or any other objects.

   This fixed the error. 
     require_once($ItemTypesDir . "ItemTypes.interface.php");
    require_once($ItemTypesDir . $iType["parentID"] . ".itemType.php");

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...