$Product class can't generate multiple new instances.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

eliezer
Forum Newbie
Posts: 11
Joined: Sat Nov 03, 2007 11:45 am

Post by eliezer »

Hi again guys.

So I managed to merge the code and to get a simple dump for the class properties and values.

But now the manager says I shall not create two classes such as $Product_$Shelf and $Product since an Invoice-generator script (wich is what he's asking me for) shouldn't go as far (and according to him "complicated") as that.
He says I should do it in a easier way. He's gettin' on my nerves!

I attach the class diagram:

Image

And here is the coding I got as far as now.

Code: Select all

<?PHP

class Invoice
	{
	private $number;
	// 'fecha' below means Date, just forgot translation on diagram...
	private $fecha;
	private $placed;
	private $shipment;
	private $plan;

	function __construct($number,$fecha,$placed,$shipment,$plan)
	{
	$this->number = $number;
	$this->fecha = $fecha;
	$this->placed = $placed;
	$this->shipment = $shipment;
	$this->plan = $plan;
	}
	function getNumber()
	{
	return $this->number;
	}
	function getFecha()
	{
	return $this->fecha;
	}
	function getPlaced()
	{
	return $this->placed;
	}
	function getShipment()
	{
	return $this->shipment;
	}
	function getPlan()
	{
	return $this->plan;
	}
}

class Agent
	{
	private $zone;
	private $nameAgent;
	private $lastNameAgent;

	function __construct($zone,$nameAgent,$lastNameAgent)
	{
	$this->zone = $zone;
	$this->nameAgent = $nameAgent;
	$this->lastNameAgent = $lastNameAgent;
	}
	function getZone()
	{
	return $this->zone;
	}
	function getnameAgent()
	{
	return $this->nameAgent;
	}
	function getlastNameAgent()
	{
	return $this->lastNameAgent;
	}
}

class Customer
	{
	private $account;
	private $nameCustomer;
	private $lastNameCustomer;
	private $addressCustomer;

	function __construct($account,$nameCustomer,$lastNameCustomer,$addressCustomer)
	{
	$this->account = $account;
	$this->nameCustomer = $nameCustomer;
	$this->lastNameCustomer = $lastNameCustomer;
	$this->addressCustomer = $addressCustomer;
	}

	function getAccount()
	{
	return $this->account;
	}
	function getnameCustomer()
	{
	return $this->nameCustomer;
	}
	function getlastNameCustomer()
	{
	return $this->lastNameCustomer;
	}
	function getaddressCustomer()
	{
	return $this->addressCustomer;
	}
}

class ShipTo
	{
	private $order;
	private $order_code;
	private $nameShipTo;
	private $lastNameShipTo;

	function __construct($order,$order_code,$nameShipTo,$lastNameShipTo)
	{
	$this->order = $order;
	$this->order_code = $order_code;
	$this->nameShipTo = $nameShipTo;
	$this->lastNameShipTo = $lastNameShipTo;
	}

	function getOrder()
	{
	return $this->order;
	}
	function getOrderCode()
	{
	return $this->order_code;
	}
	function getnameShipTo()
	{
	return $this->nameShipTo;
	}
	function getlastNameShipTo()
	{
	return $this->lastNameShipTo;
	}
}

// NOW, HERE IS WHERE I COULD USE EITHER 
// EVERAH
// OR
// JCART'S 
// CLASSES, I GUESS EVERAH SHALL DO THE JOB CAUSE IT'S JUST ONE INSTANCE
// AND THE MANAGER ASKED ME FOR THAT... BUT..
// I STILL DON'T KNOW HOW TO MERGE THE CLASS WITH THE OTHER CLASSES
// TO GENERATE ONE SINGLE INSTANCE SO I CAN CALL ANY 
// PROPERTIE OF ANY OF CURRENT CLASSES FROM ONE SINGLE INSTANCE.

// I really hate to bother, I don't even know if I am posting it in the appropiate forum.
// but damn... if the guy wants me to know what working under pressure is, he surely got it.
// worse of all, this is very probably not to be used. It's just like my introduction.

/*
 * below class ShipTo I used to have $Product and $Product_Shelf classes from JCart.
 * manager refused it that way.
 */




// create new objects:

$createInvoice = new Invoice('03096','11/11/07','Monterrey','El Charro Transportations','Credit30');
$createAgent = new Agent('Chihuahua','Victor','Villanueva');
$createCustomer = new Customer('Juan','Perez','100204');
$createShipmentTo = new ShipTo('00161','SMX10037','Datamine','Inc');

?>

Now, this code is untested, I'm not able to get data out of the company so I manually wrote my classes on a sheet and brought them home. Don't tell anyone.
I also translated the classes to english in order to show it to you guys, so there might be something wrong with the code, is just for illustrative purposes anyway I guess.

Now, this guy is really hurrying me up to finish this. I don't want to sound like I'm rushing anyone... but I need urgent help.

I know I can understand how classes work, I just need someone to show me the how-to.

Thanks a lot!

Jcart | Please use tags when posting php code[/color]
- Got it.
eliezer
Forum Newbie
Posts: 11
Joined: Sat Nov 03, 2007 11:45 am

Post by eliezer »

Well, off to bed. I think I did came up with something.

Though I don't think that sending about 15-20 array keys per object would be a good idea.

He wanted simplicity huh.
Post Reply