本文整理汇总了C#中Battery类的典型用法代码示例。如果您正苦于以下问题:C# Battery类的具体用法?C# Battery怎么用?C# Battery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Battery类属于命名空间,在下文中一共展示了Battery类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
// Create an instance of the GSM class
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-GB");
Display display = new Display(2.5F, "256K");
Battery battery = new Battery(950, 35, BatteryType.LiIon);
GSM gsmTest = new GSM("Samsung Ace", "Samsung Group", 545.00M, "Ivan Ivanov", battery, display);
//Add few calls
DateTime date = DateTime.Now;
gsmTest.AddCallInHistory(date, "0889909988", 65);
gsmTest.AddCallInHistory(date.AddHours(1), "0889969988", 25);
gsmTest.AddCallInHistory(date.AddHours(2), "0883909988", 3600);
gsmTest.AddCallInHistory(date.AddHours(6.5), "0889969988", 1000);
//Display the information about the calls.
Console.WriteLine("Print the call hisory of phone {0}", gsmTest.ModelOfGSM);
Console.WriteLine(gsmTest.PrintCallHistory());
//Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history
//use readonly modificator about pricePerminute
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Total price of calls is: {0}", gsmTest.CalcucateTotalPrice(0.37M));
Console.ForegroundColor = ConsoleColor.Gray;
//Remove the longest call from the history and calculate the total price again.
gsmTest.RemoveCallByLongestDuration();
Console.WriteLine(gsmTest.PrintCallHistory());
//Finally clear the call history and print it.
gsmTest.ClearCallHistory();
Console.WriteLine(gsmTest.PrintCallHistory());
}
开发者ID:ralikuman,项目名称:TelerikAcademy,代码行数:33,代码来源:GSMCallHistory.cs
示例2: Main
static void Main()
{
DateTime date1 = new DateTime(2013, 5, 24, 11, 11, 30);
DateTime date2 = new DateTime(2013, 5, 24, 15, 23, 2);
DateTime date3 = new DateTime(2013, 5, 31, 9, 00, 00);
DateTime date4 = new DateTime(2013, 5, 31, 18, 12, 20);
Call call1 = new Call(date1, "0888313233", 850);
Call call2 = new Call(date2, "0888909090", 95);
Call call3 = new Call(date3, "0889556677", 213);
Call call4 = new Call(date4, "0888313233", 37);
Battery battery = new Battery ("PX8", BatteryType.LiIon, 300, 8);
Display display = new Display(4, 16000000);
GSM gsm = new GSM("I900", "Samsung", 500, "Me", battery, display);
gsm.AddCalls(call1);
gsm.AddCalls(call2);
gsm.AddCalls(call3);
gsm.AddCalls(call4);
foreach (var call in gsm.CallHistory)
{
Console.WriteLine(call);
}
Console.WriteLine("Total amount to pay: {0:C}",gsm.TotalCallsPrice);
gsm.DeleteCalls(call1);
Console.WriteLine("Total amount to pay: {0:C}", gsm.TotalCallsPrice);
gsm.ClearHistory();
Console.WriteLine("Total amount to pay: {0:C}", gsm.TotalCallsPrice);
}
开发者ID:stefan-er,项目名称:CSharp,代码行数:34,代码来源:GSMCallHistoryTest.cs
示例3: GSM
public GSM(string model, string manufacturer, decimal? price, string owner, Battery battery, Display display)
: this(model, manufacturer, price)
{
this.owner = owner;
this.Battery = battery;
this.Display = display;
}
开发者ID:bankova,项目名称:CSharp,代码行数:7,代码来源:GSM.cs
示例4: CreatingBatterytWithValidDataShouldSetAllPropertiesCorrectly
public void CreatingBatterytWithValidDataShouldSetAllPropertiesCorrectly()
{
var battery = new Battery("8 cells", 4.5);
Assert.AreEqual("8 cells", battery.Description, "Battery description name is set wrong");
Assert.AreEqual(4.5, battery.LifeInHours, "Battery life in hours description is set wrong");
}
开发者ID:Y-LyN-10,项目名称:Software-University-Courses,代码行数:7,代码来源:BatteryTests.cs
示例5: Main
static void Main()
{
Console.OutputEncoding = System.Text.Encoding.UTF8;
Battery bat = new Battery(48, 49, "bat11");
Display dis = new Display(48502);
GSM phone1 = new GSM("5800", "Nokia", 850, null, bat, dis);
Console.WriteLine(phone1.Battery.HoursTalk);
Console.WriteLine(phone1.Display.Height);
Console.WriteLine(phone1.Display.Colors);
bat.BatteryType = BatteryType.NiCd;
Console.WriteLine(bat.BatteryType);
Battery bat2 = new Battery(48, 52, "dada", BatteryType.NiMH);
Console.WriteLine(bat2.BatteryType);
Console.WriteLine(phone1);
Console.WriteLine();
Console.WriteLine(GSM.Iphone4S);
GSM phone2 = new GSM("Galaxy", "Samsung");
GSM[] phones = new GSM[] {
phone1,
phone2
};
for (int i = 0; i < phones.Length; i++)
{
Console.WriteLine(phones[i]);
}
}
开发者ID:hristo11111,项目名称:TelerikAcademy-HristoBratanov,代码行数:32,代码来源:GSMTest.cs
示例6: Main
static void Main()
{
var battery = new Battery("Li-Ion, 4-cells, 2550 mAh", "4.5 hours");
var laptop = new Laptop("Lenovo Yoga 2 Pro", "2259.00 lv.", "Intel HD Graphics 4400", "128GB SSD", battery);
Console.WriteLine(laptop.ToString());
}
开发者ID:i-yotov,项目名称:Courses,代码行数:7,代码来源:LaptopShopMain.cs
示例7: Laptop
public Laptop(string model, string manufacturer, Battery elements, double price)
{
this.Model = model;
this.Price = price;
this.Manufacturer = manufacturer;
this.SetElements(elements);
}
开发者ID:HristoHristov,项目名称:OOP,代码行数:7,代码来源:Laptop.cs
示例8: Laptop
public Laptop(string model, string price, string graphicsCard, string hdd, Battery battery)
: this(model, price)
{
this.GraphicsCard = graphicsCard;
this.HDD = hdd;
this.Battery = battery;
}
开发者ID:i-yotov,项目名称:Courses,代码行数:7,代码来源:Laptop.cs
示例9: Main
static void Main()
{
//creating array of GSM phones, adding info about them
Console.WriteLine("Mobile phones: ", Console.ForegroundColor = ConsoleColor.Red);
GSM[] telephones = new GSM[3];
Console.ForegroundColor = ConsoleColor.Gray;
Battery battery = new Battery("helolModel", 1500, 1000, BatteryType.LiIon);
Display display = new Display("100x85", 256);
GSM phoneOne = new GSM("s400", "Samsung", 500, "Rosen", battery, display);
GSM phoneTwo = new GSM("Duos", "Samsung", 500, "Joro", battery, display);
GSM phoneThree = new GSM("s800", "Samsung", 500, "Tanq", battery, display);
telephones[0] = phoneOne;
telephones[1] = phoneTwo;
telephones[2] = phoneThree;
//print the info for each phone from the array
for (int i = 0; i < telephones.Length; i++)
{
Console.WriteLine(telephones[i]);
}
Console.WriteLine(GSM.IPhone4S.Model);
Console.WriteLine(GSM.IPhone4S.Manufacturer);
Console.WriteLine("\nHistory information: \n",
Console.ForegroundColor = ConsoleColor.Red);
//go to next Test.cs class
GSMCallHistoryTest.Main2();
}
开发者ID:joro1881,项目名称:CSharpProgramming,代码行数:30,代码来源:GSMTest.cs
示例10: Main
static void Main()
{
Display testDisplay = new Display(14, 16.5f);
Battery testBattery = new Battery("test");
GSM myPhone = new GSM("test", "test", "Owner",1234, testBattery, testDisplay);
Console.WriteLine(myPhone.display.Size);
}
开发者ID:nikolaZ,项目名称:TelerikAcademy,代码行数:7,代码来源:Test.cs
示例11: Main
private static void Main()
{
// Generate some test batteries and displays
var premiumDisplay = new Display(4.5, Display.ColorDepth._32Bit);
var mediocreDisplay = new Display(3.5, Display.ColorDepth._16Bit);
var poorDisplay = new Display(2.5, Display.ColorDepth._8bit);
var premiumBattery = new Battery("Sanyo-SN532e", 120, 20, Battery.Type.LiPol);
var mediocreBattery = new Battery("Shanzungmang-2341", 80, 15, Battery.Type.LiIon);
var poorBattery = new Battery("Mistucura-1224fe", 40, 5, Battery.Type.NiMH);
// initilize gsms in the array
var gsmArray = new GSM[4];
gsmArray[0] = new GSM("One", "HTC", "Kiro", premiumDisplay, premiumBattery, 200);
gsmArray[1] = new GSM("Blade", "Zte");
gsmArray[2] = new GSM("Galaxy S4", "Samsung", "Misho", premiumDisplay, mediocreBattery, 1000);
gsmArray[3] = new GSM("Ascend G600", "Huawei", "Mtel", premiumDisplay,
new Battery("Toshiba-tbsae", 380, 6, Battery.Type.LiPol), 600);
// print the gsms
foreach (var phone in gsmArray)
{
Console.WriteLine(phone);
}
// print the static property Iphone4S
Console.WriteLine(GSM.Iphone4S);
// test GsmCallHistory
GSMCallHistoryTest.Test();
}
开发者ID:hrist0stoichev,项目名称:Telerik-Homeworks,代码行数:30,代码来源:GSMTest+.cs
示例12: Main
static void Main(string[] args)
{
GSM[] gsmArray = new GSM[3];
Battery myBattery = new Battery("Nokia", 50,50, BatteryType.LiIon);
Display myDisplay = new Display(10, 1000000);
GSM firstGsm = new GSM("N8", "Nokia", 500, "Me", myBattery, myDisplay);
gsmArray[0] = firstGsm;
myBattery = new Battery("Samsung", 60, 60, BatteryType.NiCd);
myDisplay = new Display(12, 1200000);
GSM secondGsm = new GSM("Galaxy", "Samsung", 700, "Me", myBattery, myDisplay);
gsmArray[1] = secondGsm;
myBattery = new Battery("HTC", 40, 40, BatteryType.NiMH);
myDisplay = new Display(8, 800000);
GSM thirdGsm = new GSM("K8", "HTC", 450, "Me", myBattery, myDisplay);
gsmArray[2] = thirdGsm;
foreach (var item in gsmArray)
{
Console.WriteLine(item);
Console.WriteLine();
}
Console.WriteLine(GSM.IPhone4S);
GSMCallHistoryTest.Test();
}
开发者ID:kalinnikol,项目名称:TelerikAcademy-1,代码行数:28,代码来源:GSMTest.cs
示例13: Main
static void Main(string[] args)
{
try
{
//Create battery and display for the GSM
Battery battery = new Battery("BL-5C",360,7,Battery.BatteryType.LithiumLon);
Display display = new Display(3,65536);
//Create GSM
GSM gsm = new GSM("1208", "nokia", 50, "Georgi", battery, display);
//Console.WriteLine(gsm.ToString()); //Print GSM data
//Mace some calls and print the history
gsm.AddCall(new Call(new DateTime(2013, 02, 22, 19, 01, 22), "00359888888888", 200));
gsm.AddCall(new Call(new DateTime(2013,02,22,20,02,33),"0887888888",302));
gsm.AddCall(new Call(new DateTime(2013, 02, 22, 20, 30, 19), "0889-88-88-88", 178));
gsm.PrintCallHistiry();
//Calculate the price of all calls
decimal price = 0.37m;
gsm.CalculateTotalCallsPrice(price);
//Remove the longest call and calculate the price again
gsm.DeleteCall(1); //The calls in the list start from 0, so the second call(longest) is 1
gsm.CalculateTotalCallsPrice(price);
//Clear the history and print it
gsm.ClearCallHistory();
gsm.PrintCallHistiry();
}
catch (Exception ex)
{
Console.WriteLine("Error!"+ex.Message);
}
}
开发者ID:Jarolim,项目名称:TelerikAcademy-1,代码行数:35,代码来源:GSMCallHistoryTest(Main).cs
示例14: RechargeAction
public RechargeAction(EndeavourFactory factory, RobotController controller, List<Goal> goals, Dictionary<TagEnum, Tag> tagMap, Battery battery)
: base(factory, controller, goals, tagMap)
{
powerStation = getTagOfType<Tag>(TagEnum.PowerStation);
this.name = "recharge";
this.battery = battery;
}
开发者ID:autarch-design-team,项目名称:OpenCircuit,代码行数:7,代码来源:RechargeAction.cs
示例15: updateBatteries
public void updateBatteries()
{
//Create a Dictionary to hold the batteries saved in the database
Dictionary<string, Battery> batteries = new Dictionary<string, Battery>();
//Create a new connection to the database
using (SQLiteConnection m_dbConnection = new SQLiteConnection(@"Data Source=database.sqlite;Version=3;"))
{
//Open database connection
m_dbConnection.Open();
using (SQLiteCommand command = m_dbConnection.CreateCommand())
{
//Select everything from the 'batteries' table
SQLiteCommand getBatteries = new SQLiteCommand("SELECT * FROM batteries", m_dbConnection);
SQLiteDataReader reader = getBatteries.ExecuteReader();
//Read every entry in the batteries table
while (reader.Read())
{
string name = (string)reader["name"];
Battery battery = new Battery((string)reader["name"], (int)reader["weight"], (int)reader["capacity"], (string)reader["configuration"], (int)reader["discharge"], (int)reader["peakDischarge"]);
//Add the battery into the dictionary using the name as the key and a new Battery object as the value
batteries.Add(name, battery);
}
}
//Close the database connection
m_dbConnection.Close();
}
//Save the updated savedBattery list
savedBatteries = batteries;
}
开发者ID:Kriegerfaust88,项目名称:RC-Configurator,代码行数:33,代码来源:BatteryTableManager.cs
示例16: GetCurrentState
public BatteryData GetCurrentState()
{
if (battery == null)
{
battery = Battery.GetDefault();
}
BatteryData data = new BatteryData();
data.BatteryLife = battery.RemainingChargePercent;
TimeSpan dischargeTime = battery.RemainingDischargeTime;
if (dischargeTime.Days < 1000)
{
data.BatteryLifeTime = battery.RemainingDischargeTime;
data.BatteryState = BatteryState.Discharging;
}
else
{
// High discharge time means phone is charging.
data.BatteryState = BatteryState.Charging;
}
// Notify only when values changes. GetCurrentState can be called manually.
if (lastBatteryData == null || data.BatteryLife != lastBatteryData.BatteryLife || data.BatteryLifeTime != lastBatteryData.BatteryLifeTime || data.BatteryState != lastBatteryData.BatteryState)
{
BatteryStateChanged?.Invoke(this, new BatteryStateChangedEventArgs(data));
}
lastBatteryData = data;
return data;
}
开发者ID:jernejk,项目名称:UniversalBatteryService,代码行数:32,代码来源:BatteryService.cs
示例17: Main
static void Main()
{
GSM[] mobilePhones = new GSM[3];
GSM nokia = new GSM("3310", "Nokia");
nokia.AddHistory(DateTime.Now, 0998080907, 1.08);
nokia.AddHistory(DateTime.Now, 0998080907, 2132331.08);
nokia.DeleteHistory(1);
Battery sonyBattery5511 = new Battery("77ds7", 220, 10, BatteryType.NiMH);
Display sonyDisplay5511 = new Display(23, 128);
GSM sony = new GSM("5511", "Sony", 100.77m, "Pesho", sonyBattery5511, sonyDisplay5511);
GSM samsung = new GSM("4433", "samsung", 50.22m, "Gosho");
mobilePhones[0] = nokia;
mobilePhones[1] = sony;
mobilePhones[2] = samsung;
//Console.WriteLine(nokia.CalcPriceHistory(2.2m));
for (int i = 0; i < mobilePhones.Length; i++)
{
Console.WriteLine(mobilePhones[i]);
}
}
开发者ID:siropo,项目名称:Telerik_academy_homework,代码行数:26,代码来源:GMSTest.cs
示例18: GSM
//initialize the static iPhone GSM
static GSM()
{
DisplaySize iPhoneDisplaySize = new DisplaySize(1136, 640);
Display iPhoneDisplay = new Display(32000, iPhoneDisplaySize);
Battery iPhoneBattery = new Battery("Samsung", 24, 24, BatteryType.LiIon);
iPhone4S = new GSM("4S", "Apple", 1000000, iPhoneDisplay, iPhoneBattery);
}
开发者ID:ilkodzhambazov,项目名称:Telerik-Academy,代码行数:8,代码来源:GSM.cs
示例19: Laptop
public Laptop(string model,string manufacturer, string processor,
int ram, string graphicCard, string hdd, double price, string batteryType, string batteryLife)
{
if (model == "" || manufacturer == "" ||
processor == "" || graphicCard == "" || hdd == "")
{
throw new ArgumentException("Some empty laptop value except battery");
}
else if (ram < 0 || price < 0)
{
throw new ArgumentException("HDD space or price can't be negative");
}
else
{
this.model = model;
this.manufacturer = manufacturer;
this.processor = processor;
this.ram = ram;
this.graphicCard = graphicCard;
this.hdd = hdd;
this.price = price;
this.battery = new Battery();
this.battery.BatteryType = batteryType;
this.battery.BatteryLife = batteryLife;
}
}
开发者ID:KostaKanev,项目名称:myCodes,代码行数:27,代码来源:Laptop.cs
示例20: Battery
public Battery(Battery battery)
{
this.model = battery.model;
this.hoursTalk = battery.hoursIdle;
this.hoursTalk = battery.hoursTalk;
this.batteryType = battery.batteryType;
}
开发者ID:vanndann,项目名称:TelerikAcademy,代码行数:7,代码来源:Battery.cs
注:本文中的Battery类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论