当前位置: 首页>>代码示例>>C#>>正文


C# GSM.ToString方法代码示例

本文整理汇总了C#中GSM.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# GSM.ToString方法的具体用法?C# GSM.ToString怎么用?C# GSM.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GSM的用法示例。


在下文中一共展示了GSM.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

    static void Main()
    {
        GSM gsm = new GSM("nokia", "nokiaman");
        GSM gsm1 = new GSM("nokia", "nok", 9.5m);
        Battery bat = new Battery("monbat", 500, 100, BatteryType.NiMH);
        Display dis = new Display(null, 256);

        GSM gsm2 = new GSM("erik", "erik", bat);
        GSM gsm3 = new GSM("koko", "ka", dis);

        Console.WriteLine(gsm.ToString());
        Console.WriteLine("-----");
        Console.WriteLine(gsm1.ToString());
        Console.WriteLine("-----");
        Console.WriteLine(gsm2.ToString());
        Console.WriteLine("-----");
        Console.WriteLine(gsm3.ToString());

        Console.WriteLine("---------------------------");

        GSM p = GSM.IPhone4S;
        p.Owner = "pesho";
        p.Battery = bat;
        Console.WriteLine(p.ToString());

        GSMCallHistoryTest.Test();




    }
开发者ID:Varbanov,项目名称:TelerikAcademy,代码行数:31,代码来源:GSMTest.cs

示例2: Main

        static void Main()
        {
            GSM gsmTest = new GSM("Nokia", "E7");
            gsmTest.Owner = "Me";
            gsmTest.Price = 680;
            gsmTest.battery.HoursIdle = 90f;
            gsmTest.battery.Model = "BL-4";
            gsmTest.battery.Type = BatteryType.NiCd;
            gsmTest.battery.HoursTalk = 8.33f;
            gsmTest.display.ColoursCount = 16000000;
            gsmTest.display.Size = 4;
            gsmTest.call.DialedNumber = "654135416516";
            gsmTest.call.DurationInSeconds = 123;
            gsmTest.AddCall(new Call("number+3590000", 120));
            gsmTest.AddCall(new Call("number+3590001", 25));
            gsmTest.AddCall(new Call("number+3590002", 0));

            //  gsmTest.PrintSpecs();
            Console.WriteLine(gsmTest.ToString());
            //
            Console.WriteLine(gsmTest.call.DurationInSeconds);
              //  gsmTest.DeleteCall(1);
              //  gsmTest.ClearCall();
            for (int i = 0; i < gsmTest.CallHistory.Count; i++)
            {
                Console.WriteLine(gsmTest.CallHistory[i].DurationInSeconds);
            }

            Console.WriteLine("Total price of the call on phone {0} {1} is : {2}", gsmTest.Manufacturer, gsmTest.Model, gsmTest.GetTotalPriceOfCalls(0.18, gsmTest));

            Console.WriteLine(GSM.Iphone4S.battery.Model);
              //      Console.WriteLine(gsmTest.call.DurationInSeconds);
        }
开发者ID:prestress,项目名称:Telerik_Academy_Homework_Projects,代码行数:33,代码来源:Test.cs

示例3: Main

        //test the call history functionality
        static void Main()
        {
            //Create a new mobile phone
            GSM mobile = new GSM("Xperia", "Sony", 670.99, "Kitty");

            //Get information about created mobile phone
            mobile.ToString();

            //Get information about static field iPhone
            GSM.IPhone4S.ToString();

            //Add calls and print
            mobile.AddCalls(DateTime.Now, "+359 885 440 340", 1);
            mobile.AddCalls(DateTime.Now, "+359 886 789 451", 94);
            mobile.PrintCalls();

            //Delete call and print
            mobile.DeleteCalls(2);
            mobile.PrintCalls();

            //Calculate total price
            mobile.CalculateFinalPrice(0.35);

            //Clear calls and print
            mobile.ClearCalls();
        }
开发者ID:deskuuu,项目名称:TelerikAcademy,代码行数:27,代码来源:StartUp.cs

示例4: Tests

 //protected method
 public void Tests()
 {
     for (int i = 0; i < 3; i++)
     {
         GSM phone = new GSM(this.models[i], this.manifacturers[i], this.price[i], this.owners[i], this.battery[i], this.display[i]);
         Console.WriteLine(phone.ToString());
         Console.WriteLine("");
     }
     Console.WriteLine("Iphone4S ---------------------------------- ");
     Console.WriteLine(GSM.IPhone4S);
 }
开发者ID:naturalna,项目名称:OOPPrinciples,代码行数:12,代码来源:GSMTests.cs

示例5: Main

    static void Main()
    {
        try
        {
            //adding battery type i the battery constructor
            Battery batteryOne = new Battery("SameModel", 10, 20, BatteryType.LiIon);
            Console.WriteLine("-------------------------EX3---------------------------");
            Console.WriteLine(batteryOne.Type);
            // creating phone
            Display displayOne = new Display(55f);
            GSM gsm = new GSM("55k33", "Nokia", 666, "Nqkoi", batteryOne, displayOne);
            // test for override method ToString()
            Console.WriteLine("-------------------------EX4---------------------------");
            Console.WriteLine(gsm.ToString());
            Console.WriteLine("-------------------------EX.7--------------------------");
            //creating object test
            GSMTests test = new GSMTests();
            test.Tests();//call its method  It is void method so it will directly write the data
            //ex.9
            Console.WriteLine("------------------------EX9---------------------------");
            string dateTime ="22.12.2013 01.05.35";

            DateTime day = DateTime.ParseExact(dateTime, "dd.MM.yyyy HH.mm.ss", CultureInfo.InvariantCulture);//date
            string dateTime2 = "20.12.2013 01.05.35";
            DateTime day2 = DateTime.ParseExact(dateTime2, "dd.MM.yyyy HH.mm.ss", CultureInfo.InvariantCulture);//date
            Call firstCall = new Call(day,"0555555555",78);
            Call secondCall = new Call(day2, "0555555555", 105);
            Console.WriteLine(firstCall.DateAndTime);
            gsm.AddCalls(firstCall);
            gsm.AddCalls(secondCall);
            Console.WriteLine();
            Console.WriteLine(gsm.CallHistory[0].DateAndTime);
            Console.WriteLine(gsm.CallHistory[1].DateAndTime);
            Console.WriteLine("------------------------EX10--------------------------");
            gsm.DeleteCall(secondCall);
            for (int i = 0; i < gsm.CallHistory.Count; i++)
            {
                 Console.WriteLine(gsm.CallHistory[i].DateAndTime);
            }
            gsm.ClearCallHistory();
            Console.WriteLine("There is {0} call in the call history",gsm.CallHistory.Count);
            Console.WriteLine("--------------------------EX12------------------------");
            GSMCallHistoryTest testHistory = new GSMCallHistoryTest();
            testHistory.GSMCallHistoryTests();

        }
        catch (ArgumentException exep)
        {
            Console.WriteLine("There is incorrect data!");
            Console.WriteLine(exep.ToString());
        }
    }
开发者ID:naturalna,项目名称:OOPPrinciples,代码行数:52,代码来源:CreatingGsm.cs

示例6: Main

 static void Main()
 {
     //Create an instance of the GSM class.
     GSM myPhone = new GSM("One", "One Plus");
     myPhone.Owner = "I";
     myPhone.Price = 1000;
     myPhone.DisplaySize = 5;
     myPhone.DisplayNumberOfColors = 16000000;
     myPhone.battery.Type = BatteryType.LiIon;
     myPhone.battery.Model = "RBC18";
     myPhone.battery.HoursIdleTime = 426.5;
     myPhone.battery.HoursTalkTime = 24.3;
     myPhone.AddCallToList(new Call(DateTime.Now, "0885649596", 5));
     //Add few calls.
     for (int i = 10; i < 60; i = i + 5)
     {
         myPhone.AddCallToList(new Call(DateTime.Now.AddMinutes(i), "08856495" + i, i));
     }
     for (int i = 80; i > 65; i = i - 3)
     {
         myPhone.AddCallToList(new Call(DateTime.Now.AddMinutes(i), "08856495" + i, i));
     }
     Console.WriteLine(myPhone.ToString());
     //Display the information about the calls.
     foreach (var call in myPhone.CallHistory)
     {
         Console.WriteLine("{0} - Phone number: {1} - Duration: {2}", call.Time, call.PhoneNumber, call.Duration);
     }
     Console.WriteLine("Total talk time: {0}", myPhone.TotalTalkTime());
     //Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history.
     Console.WriteLine("The total price of the calls in the history is : {0}", myPhone.CallPrice(0.37M));
     //Remove the longest call from the history and calculate the total price again.
     myPhone.DeleteCallFromList(FindLongestCall(myPhone.CallHistory));
     foreach (var call in myPhone.CallHistory)
     {
         Console.WriteLine("{0} - Phone number: {1} - Duration: {2}", call.Time, call.PhoneNumber, call.Duration);
     }
     Console.WriteLine("Total talk time: {0}", myPhone.TotalTalkTime());
     Console.WriteLine("The total price of the calls in the history is : {0}", myPhone.CallPrice(0.37M));
     //Finally clear the call history and print it.
     myPhone.ClearCallHistory();
     foreach (var call in myPhone.CallHistory)
     {
         Console.WriteLine("{0} - Phone number: {1} - Duration: {2}", call.Time, call.PhoneNumber, call.Duration);
     }
     Console.WriteLine("Total talk time: {0}", myPhone.TotalTalkTime());
     Console.WriteLine("The total price of the calls in the history is : {0}", myPhone.CallPrice(0.37M));
 }
开发者ID:p0150n,项目名称:TelerikAcademy,代码行数:48,代码来源:Program.cs

示例7: Main

    static void Main()
    {
        GSM phone = new GSM("Moto X", "Motorola");

        phone.AddCall(DateTime.Now, "0899789987", 500);
        phone.AddCall(new DateTime(2013, 2, 16), "0899233987", 350);
        phone.AddCall(new DateTime(2013, 2, 12), "0899123456", 58);
        phone.AddCall(new DateTime(2013, 2, 13), "0899123456", 58);
        phone.AddCall(new DateTime(2013, 2, 14), "0899123456", 69);
        phone.AddCall(new DateTime(2013, 2, 14), "0899123456", 69);
        Console.WriteLine(phone.ToString());
        phone.ShowCallHistory();
        phone.CalcPrice(0.37M);
        phone.RemoveLongestCall();
        phone.CalcPrice(0.37M);
        phone.ClearHistory();
        phone.ShowCallHistory();
    }
开发者ID:krumov,项目名称:telerik,代码行数:18,代码来源:GSMCallHistoryTest.cs

示例8: Main

 static void Main()
 {
     GSM myGSM = new GSM("C2-01", "Nokia");
     Console.WriteLine(myGSM.ToString());
 }
开发者ID:KirilToshev,项目名称:Projects,代码行数:5,代码来源:MobileDevices.cs

示例9: PrintGSMInfo

 //metod print
 public void PrintGSMInfo(GSM gsm)
 {
     Console.WriteLine(gsm.ToString());
 }
开发者ID:kancho-kanchev,项目名称:Telerik,代码行数:5,代码来源:GSM.cs

示例10: Main

 static void Main()
 {
     GSM Samsung = new GSM("iphone", 1200, "Apple", "Pesho");
     Console.WriteLine(Samsung.ToString());
 }
开发者ID:K-Iliev,项目名称:OOP-C-Sharp,代码行数:5,代码来源:Program.cs

示例11: Main

    static void Main()
    {
        try
        {
            Battery batteryOne = new Battery("SameModel", 10, 20, BatteryType.LiIon);
            Display displayOne = new Display(55f);
            GSM gsm = new GSM("55k33", "Nokia", 666, "Nqkoi", batteryOne, displayOne);
            Console.WriteLine(gsm.ToString());
            // Console.WriteLine(batteryOne.Type);
            //ex.6

            Console.WriteLine();
        }
        catch (ArgumentException exep)
        {
            Console.WriteLine("There is incorrect data!");
            Console.WriteLine(exep.ToString());
        }
    }
开发者ID:naturalna,项目名称:OOPPrinciples,代码行数:19,代码来源:Program.cs

示例12: Main

 static void Main()
 {
     GSM iPhone = new GSM("iphone", 1200, "Apple", "Az");
     Console.WriteLine(iPhone.ToString());
     string hghgf = null;
     Console.WriteLine(hghgf);
 }
开发者ID:K-Iliev,项目名称:OOP-C-Sharp,代码行数:7,代码来源:GsmInformation.cs

示例13: Main

    public static void Main()
    {
        //Console.Write("Enter number of phones: ");
        //int number = int.Parse(Console.ReadLine());
        //GSM[] phones = new GSM[number];

        //for (int i = 0; i < number; i++)
        //{
        //    Console.Write("Enter phone model: ");
        //    string model = Console.ReadLine();
        //    Console.Write("Enter phone manifacutrer: ");
        //    string manifacture = Console.ReadLine();
        //    Console.Write("Enter phone owner: ");
        //    string owner = Console.ReadLine();
        //    Console.Write("Enter phone price: ");
        //    string price = Console.ReadLine();
        //    Console.Write("Enter phone batter model: ");
        //    string batteryModel = Console.ReadLine();
        //    Console.Write("Enter phone battery idle hours: ");
        //    string idleHours = Console.ReadLine();
        //    Console.Write("Enter phone battery talk hours: ");
        //    string talkHours = Console.ReadLine();
        //    Console.Write("Enter phone display size: ");
        //    string displaySize = Console.ReadLine();
        //    Console.Write("Enter phone number of colors: ");
        //    string displayColors = Console.ReadLine();

        //    phones[i] = new GSM(model, manifacture, owner, double.Parse(price), batteryModel, int.Parse(idleHours), int.Parse(talkHours), double.Parse(displaySize), int.Parse(displayColors));
        //}

        //foreach (var item in phones)
        //{
        //    Console.WriteLine();
        //    item.GetInfo();
              //Console.WriteLine(item.ToString());
        //    Console.WriteLine();
        //}
     
     
        
        //---------------------------------------------------------------------------------------------------//
        //CallHistoryTest
        GSM mobile = new GSM("3310", "Nokia", "Some swedish guy", 100m, "ARhd34", 310, 140, 4.3f, 16000000, BatteryType.LiIon);
        Console.WriteLine(mobile.ToString());

        //mobile.GetInfo();

        mobile.AddCalls("12:50", 0894216738, 50, 21, 12, 2013);
        mobile.AddCalls("16:23", 0894216738, 120, 21, 12, 2013);
        mobile.AddCalls("18:32", 0894216738, 23, 24, 12, 2013);
        mobile.AddCalls("12:17", 0894216738, 180, 29, 12, 2013);

        //Get info for the calls
        Console.WriteLine();
        foreach (var item in mobile.callHistory)
        {
            Console.WriteLine(item.date + " " + item.dialedNumber + " " + item.duration + " " + item.Time);
        }

        //Print total price
        Console.WriteLine();
        Console.WriteLine("Total price: {0}", mobile.CalculateTotalBill(0.37m));

        //Delete longest call and print price again
        mobile.callHistory.Remove(mobile.callHistory[3]);
        
        Console.WriteLine();
        Console.WriteLine("Total price: {0}", mobile.CalculateTotalBill(0.37m));

        //Clear call history and print again
        mobile.callHistory.Clear();

        Console.WriteLine();
        foreach (var item in mobile.callHistory)
        {
            Console.WriteLine(item.date + " " + item.dialedNumber + " " + item.duration + " " + item.Time);
        }
    }
开发者ID:ScreeM92,项目名称:Software-University,代码行数:78,代码来源:GSMTest.cs

示例14: Main

        static void Main(string[] args)
        {
            GSM justInstance = new GSM();

            //Testing full parameter ctor
            Console.WriteLine(new string('-', 80));
            GSM Nokia = new GSM("E52", "Nokia", 200.0m, "Ivan", new Battery("2000 mAh", 12.3, 4.5, BatteryType.NiMH), new Display(2.6, 16000000));
            Console.WriteLine("\nTesting full parameter ctor");
            Console.WriteLine(Nokia.ToString());

            //Testing full param ctor with default Battery and Display
            Console.WriteLine(new string('-', 80));
            GSM Nokia1 = new GSM("E52", "Nokia", 200.0m, "Ivan", new Battery(), new Display());
            Console.WriteLine("\nTesting full param ctor with default Battery and Display");
            Console.WriteLine(Nokia1.ToString());

            //Testing partial param ctor
            Console.WriteLine(new string('-', 80));
            GSM Nokia2 = new GSM("E52", "Nokia");
            Console.WriteLine("\nTesting partial param ctor");
            Console.WriteLine(Nokia2.ToString());

            ///////////////////////////TASK 7 tests//////////////////////////////
            Console.WriteLine(new string('-', 80));
            Console.WriteLine("\nTASK 7 TEST START HERE !");
            GSM[] gsmList = new GSM[5];
            for (int i = 0; i < 5; i++)
            {
                gsmList[i] = Nokia;
            }
            foreach (GSM gsm in gsmList)
            {
                Console.WriteLine(gsm.ToString() + "\n");
            }

            Console.WriteLine("\nPrinting static field iPhone4s");
            Console.WriteLine(justInstance.IPhone4s);

            ///////////////////////////TASK 10 tests////////////////////////////
            Console.WriteLine(new string('-', 80));
            Console.WriteLine("\nTASK 10 TEST START HERE !");
            GSM vladosPhone = new GSM("S35", "Siemens", 79.99m, "Vlado", new Battery("750mAh", 72, 6, BatteryType.LiIon), new Display(1.5, 64), null);
            vladosPhone.AddCalltoHistory(new Call("+359888555777",3600));
            vladosPhone.AddCalltoHistory(new Call("0000",0));
            vladosPhone.AddCalltoHistory(new Call("+359888000000",15));
            vladosPhone.AddCalltoHistory(new Call("0888555777",10));
            vladosPhone.AddCalltoHistory(new Call("028685512",20));
            vladosPhone.AddCalltoHistory(new Call("0359887551552",60));
            vladosPhone.PrintCallLog();
            vladosPhone.DeleteCallFromHistory(new Call("+359888555777"));
            vladosPhone.DeleteCallFromHistory(new Call("0000"));
            vladosPhone.DeleteCallFromHistory(new Call("+359888000000"));
            Console.WriteLine("Testing callHistory delete function:");
            vladosPhone.PrintCallLog();
            Console.WriteLine("Testing callHistory clear function:");
            vladosPhone.ClearHistory();
            vladosPhone.PrintCallLog();

            ///////////////////////////TASK 11 tests////////////////////////////
            Console.WriteLine(new string('-', 80));
            Console.WriteLine("\nTASK 11 TEST START HERE !");
            vladosPhone.AddCalltoHistory(new Call("+359888555777", 3600));
            vladosPhone.AddCalltoHistory(new Call("+359888000000", 15));
            vladosPhone.AddCalltoHistory(new Call("0359887551552", 60));
            vladosPhone.CalculatePrice();

            ///////////////////////////TASK 12 tests////////////////////////////
            Console.WriteLine(new string('-', 80));
            Console.WriteLine("\nTASK 12 TEST START HERE !");
            /*  Write a class GSMCallHistoryTest to test the call history functionality of the GSM class.
                Create an instance of the GSM class.
                Add few calls.
                Display the information about the calls.
                Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history.
                Remove the longest call from the history and calculate the total price again.
                Finally clear the call history and print it.
            */
            //Create an instance of the GSM class.
            GSM instance = new GSM();
            // Add few calls.
            instance.AddCalltoHistory(new Call("+359888555777", 3600));
            instance.AddCalltoHistory(new Call("+359888123321", 300));
            instance.AddCalltoHistory(new Call("0359888333222", 80));
            instance.AddCalltoHistory(new Call("028683939", 50));
            instance.AddCalltoHistory(new Call("+123000128937912837", 0));
            // Display the information about the calls.
            instance.PrintCallLog();
            //Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history.
            instance.CalculatePrice();
            //Remove the longest call from the history and calculate the total price again.
            instance.DeleteCallFromHistory(new Call("+359888555777"));
            instance.CalculatePrice();
            // Finally clear the call history and print it.
            instance.ClearHistory();
            instance.PrintCallLog();
        }
开发者ID:huoxudong125,项目名称:TelerikAcademy,代码行数:96,代码来源:GSMTest.cs

示例15: Main

 static void Main()
 {
     GSM gsm = new GSM("Galaxy S3", "Samsung", 899.99m, "30 milion people");
     string gsmString = gsm.ToString();
     Console.WriteLine(gsm);
 }
开发者ID:NasC0,项目名称:Telerik_Homework,代码行数:6,代码来源:OverrideToStringMethod.cs


注:本文中的GSM.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。