城南有个商店叫"兴旺通讯",实行了会员制度。会员的折扣可以调整。不过不能超过9折。
城北也有个“兴旺通讯”.没有实行会员制度.
要求:用OOP思想模拟他们的销售过程
一下是本人的代码。望大家给点建议.多多指点批评。谢谢using System;
using System.Collections.Generic;
using System.Text;namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
//south.xingwang jeck = new south.xingwang("会员"); //城南的会员销售
//south.xingwang jeck = new south.xingwang(); //城南的非会员销售
north.xingwang jeck = new north.xingwang(); //城北的销售
double price = jeck.shop(100); //购物方法。传入价格
Console.WriteLine(price); //得出最终价格
Console.ReadLine();
}
}
}namespace south //城南
{
class xingwang //兴旺通讯(商店)
{
double _disount = 0.95; //折扣率
public double Disount //可修改折扣率
{
get { return _disount; }
set
{
if(value<0.9)
{
_disount=0.9;
}else{
_disount=value;
}
}
}
public xingwang() //非会员
{
this._disount = 1;
} public xingwang(string member) //会员
{ }
public double shop(double price) //购物方法
{
price = price * this._disount; //价格=价格*折扣
return price; //返回价格
}
}
}namespace north //城北
{
class xingwang //兴旺通讯(商店)
{
public double shop(double price) //购物
{
return price; //没有折扣,直接返回价格
}
}
}
城北也有个“兴旺通讯”.没有实行会员制度.
要求:用OOP思想模拟他们的销售过程
一下是本人的代码。望大家给点建议.多多指点批评。谢谢using System;
using System.Collections.Generic;
using System.Text;namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
//south.xingwang jeck = new south.xingwang("会员"); //城南的会员销售
//south.xingwang jeck = new south.xingwang(); //城南的非会员销售
north.xingwang jeck = new north.xingwang(); //城北的销售
double price = jeck.shop(100); //购物方法。传入价格
Console.WriteLine(price); //得出最终价格
Console.ReadLine();
}
}
}namespace south //城南
{
class xingwang //兴旺通讯(商店)
{
double _disount = 0.95; //折扣率
public double Disount //可修改折扣率
{
get { return _disount; }
set
{
if(value<0.9)
{
_disount=0.9;
}else{
_disount=value;
}
}
}
public xingwang() //非会员
{
this._disount = 1;
} public xingwang(string member) //会员
{ }
public double shop(double price) //购物方法
{
price = price * this._disount; //价格=价格*折扣
return price; //返回价格
}
}
}namespace north //城北
{
class xingwang //兴旺通讯(商店)
{
public double shop(double price) //购物
{
return price; //没有折扣,直接返回价格
}
}
}
LZ刚学了属性和方法
他老师出的题。。
using System.Collections.Generic;
using System.Text;namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
south.xingwang xw = new south.xingwang ();//生成商店
double zhekou = xw.Disount; //得到折扣
south.person jeck = new south.person(); //判断会员
double price = jeck.shop(100); //会员本来应该给的钱
double endprice = xw.shop(price,zhekou); //折扣后的价钱
Console.WriteLine(zhekou);
Console.ReadLine();
}
}
}namespace south
{
class xingwang
{
double _disount = 0.95;
public double Disount
{
get { return _disount; }
set
{
if(value<0.9)
{
_disount=0.9;
}else{
_disount=value;
}
}
}
public double shop(double price, double disong)
{
price = price * disong;
return price;
}
}
class person
{
public person() //不是会员
{
south.xingwang xw = new xingwang(); //修改折扣
xw.Disount = 1;
}
public person(string member) //是会员
{
}
public double shop(double price)
{
return price;
}
}
}最新修改
using System;
using System.Collections.Generic;
using System.Text;namespace ConsoleApplication2
{
class Program
{
/// <summary>
/// 再次修改。城南商店
/// </summary>
/// <param name="args"></param>
static void Main(string[] args)
{
south.xingwang xw = new south.xingwang();//生成商店 south.person jeck = new south.person(); //生成会员 int Authentication = jeck.Member; //会员验证 xw.Authentication(Authentication); double price = jeck.shop(100); //会员本来应该给的钱 double endprice = xw.shop(price); //折扣后的价钱
Console.WriteLine(endprice);
Console.ReadLine();
}
}
}namespace south
{
class xingwang
{
double _disount = 0.95; //折扣
public double Disount //修改折扣
{
get { return _disount; }
set
{
if(value<0.9) //不能超过9折
{
_disount=0.9;
}else{
_disount=value;
}
}
}
public void Authentication(int num) //验证会员
{
if (num == 0) //0代表不是会员
{
_disount = 1; //没有折扣
}
}
public double shop(double price)
{
price = price * this._disount;
return price;
}
}
class person
{
int member = 1; //会员
public int Member
{
get { return member; }
set { member = value; }
}
public double shop(double price) //本来该给的钱
{
return price;
}
}
}namespace north
{
class xingwang
{
public double shop(double price)
{
return price;
}
} class person
{
public double shop(double price)
{
return price;
}
}
}