本文整理汇总了C#中Battery类的典型用法代码示例。如果您正苦于以下问题:C# Battery类的具体用法?C# Battery怎么用?C# Battery使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Battery类属于命名空间,在下文中一共展示了Battery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
示例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);
}
示例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;
}
示例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");
}
示例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]);
}
}
示例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());
}
示例7: Laptop
public Laptop(string model, string manufacturer, Battery elements, double price)
{
this.Model = model;
this.Price = price;
this.Manufacturer = manufacturer;
this.SetElements(elements);
}
示例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;
}
示例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();
}
示例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);
}
示例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();
}
示例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();
}
示例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);
}
}
示例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;
}
示例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;
}