帮助到你可以点个采纳吗,谢谢~~
using System;
namespace ConsoleApp1
{
class Customer
{
private string cNo { get; set; }
private string cName { get; set; }
private int cPoints { get; set; }
private string cTelephone { get; set; }
public string CNo { get { return cNo; } }
public string CName { get { return cName; } }
public int CPoints { get { return cPoints; }set{ cPoints = value; } }
public string CTelephone { get { return cTelephone; }set { cTelephone = value; } }
public Customer() { }
public void Input()
{
Console.Write("请输入客户编号:");
cNo = Console.ReadLine();
Console.Write("请输入客户姓名:");
cName = Console.ReadLine();
Console.Write("请输入客户电话:");
cTelephone = Console.ReadLine();
while (true)
{
Console.Write("请选择你的操作,1-增加积分;2-兑换积分,其他则退出--");
string op = Console.ReadLine();
if (op == "1" || op == "2")
{
Console.Write("请输入要" + (op == "1" ? "增加" : "兑换") + "的积分:");
string sScore = Console.ReadLine();
int score = 0;
if (int.TryParse(sScore, out score))
{
if (op == "1")
{
Buy(score);
Console.WriteLine("已存入{0}积分", score);
Show();
}
else
{
Exchange(score);
Console.WriteLine("本次兑换{0}积分", score);
Show();
}
}
else Console.WriteLine("积分需要为数字,请重新选择操作!");
}
else
{
Console.WriteLine("系统选择错误,退出!");
break;
}
}
}
private void Show() {
Console.WriteLine("客户编号:" + cNo + ",客户姓名:" + cName + ",客户联系电话:" + cTelephone + ",客户积分:" + cPoints);
}
public void Buy(int x)
{
this.cPoints += x;
}
public void Exchange(int c)
{
if (c > cPoints) Console.WriteLine("积分不足!");
else this.cPoints -= c;
}
}
class Program
{
static void Main(string[] args)
{
var kate = new Customer();
kate.Input();
Console.WriteLine("请安任意键继续!");
Console.ReadKey();
}
}
}
您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~
如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~
ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632