0% found this document useful (0 votes)
25 views

Product: Using Using Using Using Namespace Class

This document defines a Product class with properties and methods to represent product inventory items. The Product class contains private string properties for Name and Model that have public getters and setters. It also has a public enum property for Condition and a Price property with validation. The class contains default and parameterized constructors. Methods include a ToString() method to return a formatted string of the product details.

Uploaded by

Refilwe Leketi
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Product: Using Using Using Using Namespace Class

This document defines a Product class with properties and methods to represent product inventory items. The Product class contains private string properties for Name and Model that have public getters and setters. It also has a public enum property for Condition and a Price property with validation. The class contains default and parameterized constructors. Methods include a ToString() method to return a formatted string of the product details.

Uploaded by

Refilwe Leketi
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace shopping_inventory_asi_
{
class Product
{
//the 'name'property
private string Nname;
public string Name
{
get
{
return Nname;
}
set
{
Nname=value;
}
}
public string model
{
get;
set;
}

//the string 'model'property


private string mModel;
public string mModel
{
get
{
return mModel;
}
set
{
mMode=value;
}
}
//condition enum
public enum eproductcondition
{
GOOD,
BAD,
UGLY
};

//the condition attribute


public eproductcondition condition=eproductcondition.GOOD;

//the 'Price'property
private decimal mPrice;
public decimal Price
{
get
{
return mPrice;
}
set
{
if(value>0)
{
mPrice=value;
}
else
{//if the value given is smaller than or equal to zero
mPrice=0;
}
}
}

//empty contsructor to set up default values


public Product()
{
Name="";
model="";
Price=0;
}

//constructor with parameters


public Product(string name,string model,eproductcondition
condition,decimal price)
{
Name=name;
model=model;
condition=condition;
price=price;
}

class product
{
#region MyRegion

#endregion
//the 'name'property
private string nName;
public string Make
{
get;
}
}
}
}
#region properties

//the 'name' property


private string nName;
public string nName;
#endregion

productTracking
class product
{
Properties
constructors;
methods

#region Methods

//Tostring method
Public;override string Tostring()
{
return name+"-"+model+"in"+"condition.price:R"+ Price;
}
}

#endregion

You might also like