SlideShare a Scribd company logo
BookStore.CS


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

namespace ConsoleApplication1
{

    public delegate void EditionHandler();
    public class Book
    {
        public string Title;        // Title of the book.
        public string Author;       // Author of the book.
        public string BookType;     //Type of Book
        public decimal Price;       // Price of the book.
        public bool Paperback;      // Is it paperback?
        public EditionHandler AddEdition;
        public Book(string title, string author, decimal price, bool
paperBack)
        {
            Title = title;
            Author = author;
            Price = price;
            Paperback = paperBack;

          }

          public void ShowEditions()
          {
              if (AddEdition != null)
                  AddEdition();
          }

    }



    public delegate void PrintBook(Book book);
    public class BookDB
    {
        // List of all books in the database:
        ArrayList list = new ArrayList();

        // Add a book to the database:
        public void AddBook(string title, string author, decimal price, bool
paperBack)
        {
            list.Add(new Book(title, author, price, paperBack));
        }

          // Call a passed-in delegate on each paperback book to process it:
          public ArrayList List
{
            get
            {
                  return list;
            }
        }

        public void PrintPaperBackBooks()
        {
            decimal TotalPrice = 0, AveragePrice = 0, ctr = 0;
            foreach (Book b in list)
            {

                  if(b.Paperback)
                  {
                  Console.WriteLine(" Book Name {0}", b.Title);
                  Console.WriteLine(" Book Author {0}", b.Author);
                  Console.WriteLine(" Book Price {0:C}", b.Price);
                  Console.WriteLine(" Book Paperback {0}", b.Paperback);
                  Console.WriteLine("n");
                  TotalPrice = TotalPrice + b.Price;
                  ctr++;
                  }

            }
            AveragePrice = TotalPrice / ctr;

            Console.WriteLine("Average of Paper Back Books is : {0:C}",
AveragePrice);
        }

        public void PrintAllBooks()
        {
            foreach (Book b in list)
            {
                Console.WriteLine(" Book   Name {0}", b.Title);
                Console.WriteLine(" Book   Author {0}", b.Author);
                Console.WriteLine(" Book   Price {0}", b.Price);
                Console.WriteLine(" Book   Paperback {0}", b.Paperback);
                Console.WriteLine("n");
            }
        }


    }

}
Program.cs
using   System;
using   System.Collections.Generic;
using   System.Linq;
using   System.Text;

namespace ConsoleApplication1
                                       {
    class Program
    {
        static void Main(string[] args)
        {
            BookDB bookDB = new BookDB();

              // Initialize the database with some books:
              AddBooks(bookDB);
              printHeader();
              bookDB.PrintPaperBackBooks();

              Book b1 = (Book)bookDB.List[0];
              b1.AddEdition = Edition1;
              b1.AddEdition += Edition2;
              b1.AddEdition += Edition3;

              b1.ShowEditions();



          }

        static void printHeader()
        {
            Console.WriteLine("Printing Book Details as on {0}",
DateTime.Now.ToString("dd-MMM-yyyy"));
            Console.WriteLine("n");


          }
          static void AddBooks(BookDB bookDB)
          {
              bookDB.AddBook("The C Programming Language",
                 "Brian W. Kernighan and Dennis M. Ritchie", 19.95m, true);
              bookDB.AddBook("The Unicode Standard 2.0",
                 "The Unicode Consortium", 39.95m, true);
              bookDB.AddBook("The MS-DOS Encyclopedia",
                 "Ray Duncan", 129.95m, false);
              bookDB.AddBook("Dogbert's Clues for the Clueless",
                 "Scott Adams", 12.00m, true);
          }

          static void Edition1()
          {
              Console.WriteLine("Edition1 added");
          }
static void Edition2()
        {
            Console.WriteLine("Edition2 added");
        }
        static void Edition3()
        {
            Console.WriteLine("Edition3 added");
        }

    }
}

More Related Content

What's hot

Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDB
MongoDB
 
Paris Kafka Meetup - How to develop with Kafka
Paris Kafka Meetup - How to develop with KafkaParis Kafka Meetup - How to develop with Kafka
Paris Kafka Meetup - How to develop with Kafka
Florian Hussonnois
 
Cassandra Day NY 2014: Apache Cassandra & Python for the The New York Times ⨍...
Cassandra Day NY 2014: Apache Cassandra & Python for the The New York Times ⨍...Cassandra Day NY 2014: Apache Cassandra & Python for the The New York Times ⨍...
Cassandra Day NY 2014: Apache Cassandra & Python for the The New York Times ⨍...
DataStax Academy
 
Mongo sharding
Mongo shardingMongo sharding
Mongo sharding
Nik Kul
 
杨卫华:微博cache设计浅谈
杨卫华:微博cache设计浅谈杨卫华:微博cache设计浅谈
杨卫华:微博cache设计浅谈
Leechael
 
What's new in Ansible 2.0
What's new in Ansible 2.0What's new in Ansible 2.0
What's new in Ansible 2.0
Allan Denot
 
Comets notes
Comets notesComets notes
Comets notes
Ilija Dukovski
 
Node36
Node36Node36
Drinking from the firehose: Logging at scale with ELK
Drinking from the firehose: Logging at scale with ELKDrinking from the firehose: Logging at scale with ELK
Drinking from the firehose: Logging at scale with ELK
Cteodorski
 
Shell Tips & Tricks
Shell Tips & TricksShell Tips & Tricks
Shell Tips & Tricks
MongoDB
 
Statim, time series interface for Perl.
Statim, time series interface for Perl.Statim, time series interface for Perl.
Statim, time series interface for Perl.
Thiago Rondon
 
"Работа с утечками в V8", Роман Кривцов, MoscowJS 19
"Работа с утечками в V8", Роман Кривцов, MoscowJS 19"Работа с утечками в V8", Роман Кривцов, MoscowJS 19
"Работа с утечками в V8", Роман Кривцов, MoscowJS 19
MoscowJS
 
Kubernetes Nedir?
Kubernetes Nedir?Kubernetes Nedir?
Kubernetes Nedir?
AnkaraCloud
 
A quick preview of WP CLI - Chennai WordPress Meetup
A quick preview of WP CLI - Chennai WordPress MeetupA quick preview of WP CLI - Chennai WordPress Meetup
A quick preview of WP CLI - Chennai WordPress Meetup
Sudar Muthu
 
JEP 286 Local-Variable Type Inference - Ted's Tool Time
JEP 286 Local-Variable Type Inference - Ted's Tool TimeJEP 286 Local-Variable Type Inference - Ted's Tool Time
JEP 286 Local-Variable Type Inference - Ted's Tool Time
Ted Vinke
 
Exec Sp
Exec SpExec Sp
Exec Sp
luckydragon
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
Alex Bilbie
 
The Directions Pipeline at Mapbox - AWS Meetup Berlin June 2015
The Directions Pipeline at Mapbox - AWS Meetup Berlin June 2015The Directions Pipeline at Mapbox - AWS Meetup Berlin June 2015
The Directions Pipeline at Mapbox - AWS Meetup Berlin June 2015
Johan
 

What's hot (18)

Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDB
 
Paris Kafka Meetup - How to develop with Kafka
Paris Kafka Meetup - How to develop with KafkaParis Kafka Meetup - How to develop with Kafka
Paris Kafka Meetup - How to develop with Kafka
 
Cassandra Day NY 2014: Apache Cassandra & Python for the The New York Times ⨍...
Cassandra Day NY 2014: Apache Cassandra & Python for the The New York Times ⨍...Cassandra Day NY 2014: Apache Cassandra & Python for the The New York Times ⨍...
Cassandra Day NY 2014: Apache Cassandra & Python for the The New York Times ⨍...
 
Mongo sharding
Mongo shardingMongo sharding
Mongo sharding
 
杨卫华:微博cache设计浅谈
杨卫华:微博cache设计浅谈杨卫华:微博cache设计浅谈
杨卫华:微博cache设计浅谈
 
What's new in Ansible 2.0
What's new in Ansible 2.0What's new in Ansible 2.0
What's new in Ansible 2.0
 
Comets notes
Comets notesComets notes
Comets notes
 
Node36
Node36Node36
Node36
 
Drinking from the firehose: Logging at scale with ELK
Drinking from the firehose: Logging at scale with ELKDrinking from the firehose: Logging at scale with ELK
Drinking from the firehose: Logging at scale with ELK
 
Shell Tips & Tricks
Shell Tips & TricksShell Tips & Tricks
Shell Tips & Tricks
 
Statim, time series interface for Perl.
Statim, time series interface for Perl.Statim, time series interface for Perl.
Statim, time series interface for Perl.
 
"Работа с утечками в V8", Роман Кривцов, MoscowJS 19
"Работа с утечками в V8", Роман Кривцов, MoscowJS 19"Работа с утечками в V8", Роман Кривцов, MoscowJS 19
"Работа с утечками в V8", Роман Кривцов, MoscowJS 19
 
Kubernetes Nedir?
Kubernetes Nedir?Kubernetes Nedir?
Kubernetes Nedir?
 
A quick preview of WP CLI - Chennai WordPress Meetup
A quick preview of WP CLI - Chennai WordPress MeetupA quick preview of WP CLI - Chennai WordPress Meetup
A quick preview of WP CLI - Chennai WordPress Meetup
 
JEP 286 Local-Variable Type Inference - Ted's Tool Time
JEP 286 Local-Variable Type Inference - Ted's Tool TimeJEP 286 Local-Variable Type Inference - Ted's Tool Time
JEP 286 Local-Variable Type Inference - Ted's Tool Time
 
Exec Sp
Exec SpExec Sp
Exec Sp
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
The Directions Pipeline at Mapbox - AWS Meetup Berlin June 2015
The Directions Pipeline at Mapbox - AWS Meetup Berlin June 2015The Directions Pipeline at Mapbox - AWS Meetup Berlin June 2015
The Directions Pipeline at Mapbox - AWS Meetup Berlin June 2015
 

Viewers also liked

C# interview
C# interviewC# interview
C# interview
Thomson Reuters
 
All .net Interview questions
All .net Interview questionsAll .net Interview questions
All .net Interview questions
Asad Masood Qazi
 
Data Structure In C#
Data Structure In C#Data Structure In C#
Data Structure In C#
Shahzad
 
Top 100 .Net Interview Questions and Answer
Top 100 .Net Interview Questions and AnswerTop 100 .Net Interview Questions and Answer
Top 100 .Net Interview Questions and Answer
Vineet Kumar Saini
 
C# interview quesions
C# interview quesionsC# interview quesions
C# interview quesions
Shashwat Shriparv
 
C# console programms
C# console programmsC# console programms
C# console programms
Yasir Khan
 
Pattern printing programs
Pattern printing programsPattern printing programs
Pattern printing programs
Mukesh Tekwani
 
Writing High Quality Code in C#
Writing High Quality Code in C#Writing High Quality Code in C#
Writing High Quality Code in C#
Svetlin Nakov
 
How the Best of the Best are Becoming The Best with Values-Based Leadership
How the Best of the Best are Becoming The Best with Values-Based LeadershipHow the Best of the Best are Becoming The Best with Values-Based Leadership
How the Best of the Best are Becoming The Best with Values-Based Leadership
Wiley
 
Red r assignment(1)
Red r assignment(1)Red r assignment(1)
Red r assignment(1)
savisthri
 
Tech week 1 assignment
Tech week 1 assignmentTech week 1 assignment
Tech week 1 assignment
sierra98
 
Confidentiality security week 1 assignment
Confidentiality security week 1 assignmentConfidentiality security week 1 assignment
Confidentiality security week 1 assignment
DIKRIS4595
 
Tech week 1 assignment
Tech week 1 assignmentTech week 1 assignment
Tech week 1 assignment
sierra98
 
Edutech week 1 assignment
Edutech week 1 assignmentEdutech week 1 assignment
Edutech week 1 assignment
Heather Kimble
 
Week 1 assignment
Week 1 assignmentWeek 1 assignment
Week 1 assignment
anarce6217
 
Dq 2 week 3 tcp freindly
Dq 2 week  3 tcp freindlyDq 2 week  3 tcp freindly
Dq 2 week 3 tcp freindly
Raul Bernardino, BSc MSc
 
Tech week 1 assignment Wendy
Tech week 1 assignment WendyTech week 1 assignment Wendy
Tech week 1 assignment Wendy
sierra98
 
Gameplay assignment week 1
Gameplay assignment week 1Gameplay assignment week 1
Gameplay assignment week 1
SeanClarke1
 
Tech week 1 assignment
Tech week 1 assignmentTech week 1 assignment
Tech week 1 assignment
sierra98
 
R bernardino hand_in_assignment_week_1
R bernardino hand_in_assignment_week_1R bernardino hand_in_assignment_week_1
R bernardino hand_in_assignment_week_1
Raul Bernardino, BSc MSc
 

Viewers also liked (20)

C# interview
C# interviewC# interview
C# interview
 
All .net Interview questions
All .net Interview questionsAll .net Interview questions
All .net Interview questions
 
Data Structure In C#
Data Structure In C#Data Structure In C#
Data Structure In C#
 
Top 100 .Net Interview Questions and Answer
Top 100 .Net Interview Questions and AnswerTop 100 .Net Interview Questions and Answer
Top 100 .Net Interview Questions and Answer
 
C# interview quesions
C# interview quesionsC# interview quesions
C# interview quesions
 
C# console programms
C# console programmsC# console programms
C# console programms
 
Pattern printing programs
Pattern printing programsPattern printing programs
Pattern printing programs
 
Writing High Quality Code in C#
Writing High Quality Code in C#Writing High Quality Code in C#
Writing High Quality Code in C#
 
How the Best of the Best are Becoming The Best with Values-Based Leadership
How the Best of the Best are Becoming The Best with Values-Based LeadershipHow the Best of the Best are Becoming The Best with Values-Based Leadership
How the Best of the Best are Becoming The Best with Values-Based Leadership
 
Red r assignment(1)
Red r assignment(1)Red r assignment(1)
Red r assignment(1)
 
Tech week 1 assignment
Tech week 1 assignmentTech week 1 assignment
Tech week 1 assignment
 
Confidentiality security week 1 assignment
Confidentiality security week 1 assignmentConfidentiality security week 1 assignment
Confidentiality security week 1 assignment
 
Tech week 1 assignment
Tech week 1 assignmentTech week 1 assignment
Tech week 1 assignment
 
Edutech week 1 assignment
Edutech week 1 assignmentEdutech week 1 assignment
Edutech week 1 assignment
 
Week 1 assignment
Week 1 assignmentWeek 1 assignment
Week 1 assignment
 
Dq 2 week 3 tcp freindly
Dq 2 week  3 tcp freindlyDq 2 week  3 tcp freindly
Dq 2 week 3 tcp freindly
 
Tech week 1 assignment Wendy
Tech week 1 assignment WendyTech week 1 assignment Wendy
Tech week 1 assignment Wendy
 
Gameplay assignment week 1
Gameplay assignment week 1Gameplay assignment week 1
Gameplay assignment week 1
 
Tech week 1 assignment
Tech week 1 assignmentTech week 1 assignment
Tech week 1 assignment
 
R bernardino hand_in_assignment_week_1
R bernardino hand_in_assignment_week_1R bernardino hand_in_assignment_week_1
R bernardino hand_in_assignment_week_1
 

More from application developer

Chapter 26
Chapter 26Chapter 26
Chapter 25
Chapter 25Chapter 25
Chapter 23
Chapter 23Chapter 23
Next step job board (Assignment)
Next step job board (Assignment)Next step job board (Assignment)
Next step job board (Assignment)
application developer
 
Chapter 19
Chapter 19Chapter 19
Chapter 18
Chapter 18Chapter 18
Chapter 17
Chapter 17Chapter 17
Chapter 16
Chapter 16Chapter 16
Week 3 assignment
Week 3 assignmentWeek 3 assignment
Week 3 assignment
application developer
 
Chapter 15
Chapter 15Chapter 15
Chapter 14
Chapter 14Chapter 14
Chapter 13
Chapter 13Chapter 13
Chapter 12
Chapter 12Chapter 12
Chapter 11
Chapter 11Chapter 11
Chapter 10
Chapter 10Chapter 10
C # test paper
C # test paperC # test paper
C # test paper
application developer
 
Chapter 9
Chapter 9Chapter 9
Chapter 8 part2
Chapter 8   part2Chapter 8   part2
Chapter 8 part2
application developer
 
Chapter 8 part1
Chapter 8   part1Chapter 8   part1
Chapter 8 part1
application developer
 

More from application developer (20)

Chapter 26
Chapter 26Chapter 26
Chapter 26
 
Chapter 25
Chapter 25Chapter 25
Chapter 25
 
Chapter 23
Chapter 23Chapter 23
Chapter 23
 
Assignment
AssignmentAssignment
Assignment
 
Next step job board (Assignment)
Next step job board (Assignment)Next step job board (Assignment)
Next step job board (Assignment)
 
Chapter 19
Chapter 19Chapter 19
Chapter 19
 
Chapter 18
Chapter 18Chapter 18
Chapter 18
 
Chapter 17
Chapter 17Chapter 17
Chapter 17
 
Chapter 16
Chapter 16Chapter 16
Chapter 16
 
Week 3 assignment
Week 3 assignmentWeek 3 assignment
Week 3 assignment
 
Chapter 15
Chapter 15Chapter 15
Chapter 15
 
Chapter 14
Chapter 14Chapter 14
Chapter 14
 
Chapter 13
Chapter 13Chapter 13
Chapter 13
 
Chapter 12
Chapter 12Chapter 12
Chapter 12
 
Chapter 11
Chapter 11Chapter 11
Chapter 11
 
Chapter 10
Chapter 10Chapter 10
Chapter 10
 
C # test paper
C # test paperC # test paper
C # test paper
 
Chapter 9
Chapter 9Chapter 9
Chapter 9
 
Chapter 8 part2
Chapter 8   part2Chapter 8   part2
Chapter 8 part2
 
Chapter 8 part1
Chapter 8   part1Chapter 8   part1
Chapter 8 part1
 

Recently uploaded

Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
sayalidalavi006
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 

Recently uploaded (20)

Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 

Week 1 assignment q2

  • 1. BookStore.CS using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; namespace ConsoleApplication1 { public delegate void EditionHandler(); public class Book { public string Title; // Title of the book. public string Author; // Author of the book. public string BookType; //Type of Book public decimal Price; // Price of the book. public bool Paperback; // Is it paperback? public EditionHandler AddEdition; public Book(string title, string author, decimal price, bool paperBack) { Title = title; Author = author; Price = price; Paperback = paperBack; } public void ShowEditions() { if (AddEdition != null) AddEdition(); } } public delegate void PrintBook(Book book); public class BookDB { // List of all books in the database: ArrayList list = new ArrayList(); // Add a book to the database: public void AddBook(string title, string author, decimal price, bool paperBack) { list.Add(new Book(title, author, price, paperBack)); } // Call a passed-in delegate on each paperback book to process it: public ArrayList List
  • 2. { get { return list; } } public void PrintPaperBackBooks() { decimal TotalPrice = 0, AveragePrice = 0, ctr = 0; foreach (Book b in list) { if(b.Paperback) { Console.WriteLine(" Book Name {0}", b.Title); Console.WriteLine(" Book Author {0}", b.Author); Console.WriteLine(" Book Price {0:C}", b.Price); Console.WriteLine(" Book Paperback {0}", b.Paperback); Console.WriteLine("n"); TotalPrice = TotalPrice + b.Price; ctr++; } } AveragePrice = TotalPrice / ctr; Console.WriteLine("Average of Paper Back Books is : {0:C}", AveragePrice); } public void PrintAllBooks() { foreach (Book b in list) { Console.WriteLine(" Book Name {0}", b.Title); Console.WriteLine(" Book Author {0}", b.Author); Console.WriteLine(" Book Price {0}", b.Price); Console.WriteLine(" Book Paperback {0}", b.Paperback); Console.WriteLine("n"); } } } }
  • 3. Program.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { BookDB bookDB = new BookDB(); // Initialize the database with some books: AddBooks(bookDB); printHeader(); bookDB.PrintPaperBackBooks(); Book b1 = (Book)bookDB.List[0]; b1.AddEdition = Edition1; b1.AddEdition += Edition2; b1.AddEdition += Edition3; b1.ShowEditions(); } static void printHeader() { Console.WriteLine("Printing Book Details as on {0}", DateTime.Now.ToString("dd-MMM-yyyy")); Console.WriteLine("n"); } static void AddBooks(BookDB bookDB) { bookDB.AddBook("The C Programming Language", "Brian W. Kernighan and Dennis M. Ritchie", 19.95m, true); bookDB.AddBook("The Unicode Standard 2.0", "The Unicode Consortium", 39.95m, true); bookDB.AddBook("The MS-DOS Encyclopedia", "Ray Duncan", 129.95m, false); bookDB.AddBook("Dogbert's Clues for the Clueless", "Scott Adams", 12.00m, true); } static void Edition1() { Console.WriteLine("Edition1 added"); }
  • 4. static void Edition2() { Console.WriteLine("Edition2 added"); } static void Edition3() { Console.WriteLine("Edition3 added"); } } }