Tuesday, April 2, 2013

Cell Phone Class in C#


Cell Class Code

Program:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CellPhone
{
    class cellphone
    {
        string Name;
        string model;
        string made;
        string IMEI;
        string camera;
        int storage;
        int extStorage;


        public void Data()
        {
            Console.WriteLine("Enter Name of Cell phone: ");
            Name = Console.ReadLine();
            Console.WriteLine("");
            Console.WriteLine("ENter model #: ");
            model = Console.ReadLine();
            Console.WriteLine("");
            Console.WriteLine("made in: ");
            made = Console.ReadLine();
            Console.WriteLine("");
            Console.WriteLine("Enter IMEI code: ");
            IMEI = Console.ReadLine();
            Console.WriteLine("");
            Console.WriteLine("Camera or simple non-camera?: ");
            camera = Console.ReadLine();
            Console.WriteLine("");
            Console.WriteLine("internal Storage capacity in Mb: ");
            storage = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("");
            Console.WriteLine("Enter external storage Gb: ");
            extStorage = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("");

        }
        public void Display()
        {
            Console.WriteLine("            Name:       {0}", Name);
            Console.WriteLine("");
            Console.WriteLine("        Model is: {0}", model);
            Console.WriteLine("");
            Console.WriteLine("         Made in: {0}", made);
            Console.WriteLine("");
            Console.WriteLine("       IMEI # is: {0}", IMEI);
            Console.WriteLine("");
            Console.WriteLine("       Megapixel:{0}", camera);
            Console.WriteLine("");
            Console.WriteLine(" Internal sorage: {0}", storage);
            Console.WriteLine("");
            Console.WriteLine("External storage: {0}", extStorage);
            Console.WriteLine("");

        }
    }
    class program1
    {
        static void Main(string[] args)
        {
            cellphone c1 = new cellphone();
            c1.Data();
            c1.Display();
        }
    }
}


No comments:

Post a Comment