Skip to main content

C# basic code using functions | MODERN PROGRAMMING LANGUAGE

TASK:    
                MAKE A PROGRAM USING ENUM METHOD:


 PROGRAM:   MAKE A PROGRAM THAT DISPLAYS A BAG AND INSIDE A BAG TOTAL NUMBER OF BOOKS AND PEN.


CODE:

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

namespace bag
{
    public class bagd
    {
        public double price;
        public string color;
        private List<Object> l;
        public bagd(double p, string c)
        {
            price = p;
            color = c;
            l = new List<Object>();
        }

        public void PrintDetail()
        {
            Console.WriteLine("\n BAG PRICE : " + price +
                " \nBAG Color : " + color + "\nTotal Items in This Bag = :" + TotalItem());

            foreach (var item in l)
            {
                Console.WriteLine("\t " + item.ToString());
            }
        }
        public int TotalItem()
        {
            return l.Count;
        }
        public void AddItem(Object bobject)
        {
            l.Add(bobject);
        }

        public class Pen
        {
            public double penprice;
            public string pencolor;
            public Pen(double p, string c)
            {
                this.penprice = p;
                this.pencolor = c;

            }
            public override string ToString()
            {
                return "\n PEN PRICE : RS " + penprice +
                    " \n PEN Color : " + pencolor;
            }




        }
        public class books
        {
            public double bookprice;
            public string aurthorname;
            public string bookname;

            public books(double bp, string an, string bn)
            {
                bookprice = bp;
                aurthorname = an;
                bookname = bn;


            }
            public override string ToString()
            {
                return " \n Book Name : " + bookname +
                                   " \n Author Name : " + aurthorname +
                                   " \n Book Price : " + bookprice;
            }


        }

        class Program
        {
            static void Main(string[] args)
            {

                bagd b1 = new bagd(4000, "black");
                b1.AddItem(new books(100, "ejaz", "how to draw"));
                b1.AddItem(new Pen(45, "black"));
              
                b1.PrintDetail();


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



            }
        }


    }
}

Comments

Popular posts from this blog

DATA LOGIC DESIGN
                  Software Engineering  a report on:                      "Standards" What is meant by Standard? A level of quality or attainment Something used as a measure , norm or model in comparative evaluations Used or accepted as normal or average What is Software Engineering Standard? Standards are documented agreements containing technical specifications or other precise criteria to be used consistently as rules, guidelines or definitions of characteristics, to ensure that materials, products, processes and services are fit for their purpose. [ISO 1997] Standards are about providing rules, guidelines and heuristics which, if followed deliver an assurance of “good practice” – they are not intended to be about “best practice”. Why adopt a standard? As a means of transferring ‘good practice’ in software engineering As a result of the deman...