我应该为库存管理应用程序制作一个 php 程序。
我有主程序,还有一个测试程序,以确保一切正常
我确实有大部分工作的代码
库存.php
class Product
{
// ----------------------------------------- Properties -----------------------------------------
private $product_name = "no name";
private $product_code = 0;
private $product_price = 0;
private $product_quantity = 0;
private $product_needs = "no needs";
private $error_message = "??";
// ---------------------------------- Set Methods ----------------------------------------------
function set_product_name($value)
{
$error_message = TRUE;
(ctype_alpha($value) && strlen($value) <= 20) ? $this->product_name = $value : $this->error_message = FALSE;
return $this->error_message;
}
function set_product_code($value)
{
$error_message = TRUE;
(ctype_digit($value) && ($value > 0 && $value <= 6)) ? $this->product_code = $value : $this->error_message = FALSE;
return $this->error_message;
}
function set_product_price($value)
{
$error_message = TRUE;
(ctype_digit($value) && ($value > 0 && $value <= 6)) ? $this->product_price = $value : $this->error_message = FALSE;
return $this->error_message;
}
function set_product_quantity($value)
{
$error_message = TRUE;
(ctype_digit($value) && ($value > 0 && $value <= 6)) ? $this->product_quantity = $value : $this->error_message = FALSE;
return $this->error_message;
}
function set_product_needs($value)
{
$error_message = TRUE;
(ctype_alpha($value) && strlen($value) <= 40) ? $this->product_needs = $value : $this->error_message = FALSE;
return $this->error_message;
}
// ----------------------------------------- Get Methods ------------------------------------------------------------
function get_product_name()
{
return $this->product_name;
}
function get_product_code()
{
return $this->product_code;
}
function get_product_price()
{
return $this->product_price;
}
function get_product_quantity()
{
return $this->product_quantity;
}
function get_product_needs()
{
return $this->product_needs;
}
繁星淼淼
缥缈止盈