请设计一个手机类,思考手机的各种属性和方法,然后展示手机的信息,用手机的方法模拟手机的功能。

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

namespace Phone
{
//请设计一个手机类,思考手机的各种属性和方法,
//然后展示手机的信息,用手机的方法模拟手机的功能。
class Phone
{
public string nature="智能机";//手机性质
public string brand { get; set; }//品牌
public string model { get; set; }//型号
public int price { get; set; }//售价
public string phonenumber { get; set; }//手机号码
public void ShowPhoneInfo()
{
Console.WriteLine($"手机信息:\n类型:{nature}\n品牌:{brand}\n型号:{model}\n售价:{price}");
}
public string CellPhone()
{
return phonenumber;
}
//public string show()
//{
// return brand;
//}
}
}

//在主方法中调用

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

namespace Phone
{
class Program
{
static void Main(string[] args)
{
Apple apple = new Apple();
apple.ApplePhone();
Console.ReadKey();
}
class Apple
{
public void ApplePhone()
{
Phone phone = new Phone();
phone.brand = "iPhone";
phone.model = "XR";
phone.price = 3299;
phone.ShowPhoneInfo();
}
}
}
}

猜你喜欢

转载自www.cnblogs.com/NETer-P/p/12801383.html
今日推荐