(Solved Homework): Your submission should include hard copies of all 3 classes and the output from running the program using the follo…

Write a console application to meet the following requirements.  Create a system for a simple library.  The library has a name and a list of books.  Each book has a title, author and an int as the id number.  Define classes for both the library and the book.  The library should have methods for adding a book to the library, to search for a book by title, to sort and display information about all of the books and to delete a book (by title) from the library.  You will need to write 3 sort methods.  One for sorting by title, one for sorting by author and one for sorting by idnum.  Each sort must use a different process, i.e. one uses a bubble sort, one uses a selection sort and one uses an insertion sort.

The following conditions apply to the books in the library:

Don't use plagiarized sources. Get Your Custom Essay on
(Solved Homework): Your submission should include hard copies of all 3 classes and the output from running the program using the follo…
Get an essay WRITTEN FOR YOU, Plagiarism free, and by an EXPERT!
Order Essay

Each book�s name is unique.  There are no duplicate titles. When adding a book, ensure that the title doesn�t already exist.  If it does exist, don�t let the new book be added.

There is only one copy of each book in the library.

An author may have more than one book in the library.

Complete the code in this incomplete client designed to test the classes and their functionality.  You should not change any of the other code in main.

class MainClass

{

public static void Main (string[] args)

{

Library lib = new Library ();

lib.AddBook (“C# programming”, “Gesick”, 4);

lib.AddBook (“java programming”, “Roth”, 2);

lib.AddBook (“C++ programming”, “Franklin”, 1);

lib.AddBook (“unity programming”, “Preston”, 3);

lib.AddBook (“graphics & multimedia”, “Chastine”, 5);

printMenu ();

string p = Console.ReadLine ();

p = p.ToUpper ();

char pick = p [0];

 

while (pick!=’Q’) {

switch (pick) {

case ‘A’:

//insert code here for adding a book

break;

case ‘S’:

//insert code here for finding a book and

//printing its details

break;

case ‘D’:

//insert code here for displaying all of the books in the library

// alphabetically by title

break;

case ‘E’:

//insert code here for displaying all of the books in the library

// alphabetically by author

break;

case ‘F’:

//insert code here for displaying all of the books in the library

// in ascending order by id num

break;

case ‘R’:

//insert code here for removing a book                                                                         break;

default:

Console.WriteLine (“nInvalid choice, please re-enter”);

break;

}

printMenu ();

p = Console.ReadLine ();

p = p.ToUpper ();

pick = p [0];

}

 

Console.WriteLine (“good bye”);

 

}

public static void printMenu ()

{

Console.WriteLine (“nSelect one of the following:nn” +

” A  to add a book to the libraryn” +

” S  to search for a book by titlen” +

” D  to display the contents of the library, alphabetically  by title n” +

” E  to display the contents of the library, alphabetically  by author n” +

” F  to display the contents of the library, in ascending order by id num n” +

” R  to remove a book from the libraryn” +

” Q  to quit this programnn”);

Console.Write (“enter choice here: “);

 

}

}

Your submission should include hard copies of all 3 classes and the output from running the program using the following options:  D, A ( add a book of your own), e, s for a book in the library, s for a book not in the library, r for a book in the library, r for a book not in the library, f, and q.

Expert Answer

 

Below is your program. Let me know if you have any issue in comments

using System;

using System.Collections.Generic;

using System.Linq;

namespace MainClass

{

class MainClass

{

public static void Main (string[] args)

{

Library lib = new Library(“Library 1”);

lib.AddBook (“C# programming”, “Gesick”, 4);

lib.AddBook (“java programming”, “Roth”, 2);

lib.AddBook (“C++ programming”, “Franklin”, 1);

lib.AddBook (“unity programming”, “Preston”, 3);

lib.AddBook (“graphics & multimedia”, “Chastine”, 5);

printMenu ();

string p = Console.ReadLine ();

p = p.ToUpper ();

char pick = p [0];

while (pick!=’Q’) {

switch (pick) {

case ‘A’:

Console.WriteLine (“Please insert a title for the new book.”);

string t = Console.ReadLine();

int ab = Library.Search(t);

if(ab == -1)

{

Console.WriteLine (“Please insert an author for the new book.”);

string a = Console.ReadLine();

int numb = Library.GetBookCount();

lib.AddBook (t, a, numb + 1);

Console.WriteLine(“Book successfully added!”);

}

else

{

Console.WriteLine (“Book title already exists!”);

break;

}

break;

case ‘S’:

Console.WriteLine (“Please type a book title to search: “);

string s = Console.ReadLine ();

int result = Library.Search(s);

if(result == -1)

{

Console.WriteLine(“Book not found.”);

}

break;

case ‘D’:

Console.WriteLine(lib.ToStringTitle());

break;

case ‘E’:

Console.WriteLine(lib.ToStringAuthor());

break;

case ‘F’:

Console.WriteLine(lib.ToStringID());

break;

case ‘R’:

Console.WriteLine (“Please type a book title to remove: “);

string y = Console.ReadLine ();

Library.RemoveBook(y);

Console.WriteLine (“Book successfully removed!”);

break;

default:

Console.WriteLine (“nInvalid choice, please re-enter”);

break;

}

printMenu ();

p = Console.ReadLine ();

p = p.ToUpper ();

pick = p [0];

}

Console.WriteLine (“good bye”);

}

public static void printMenu ()

{

Console.WriteLine (“nSelect one of the following:nn” +

” A to add a book to the libraryn” +

” S to search for a book by titlen” +

” D to display the contents of the library, alphabetically by title n” +

” E to display the contents of the library, alphabetically by author n” +

” F to display the contents of the library, in ascending order by id num n” +

” R to remove a book from the libraryn” +

” Q to quit this programnn”);

Console.Write (“enter choice here: “);

}

}

public class Library

{

private string libName;

static List<Book> bookTitles = new List<Book>();

public Library(string x)

{

libName = x;

}

public void AddBook(string t, string a, int ident)

{

Book book = new Book (t, a, ident);

bookTitles.Add (book);

}

public override string ToString()

{

string h = “”;

foreach (Book z in bookTitles) {

h += z.ToString ();

h += “n”;

}

return h;

}

public string ToStringTitle()

{

string h = “”;

var sortedList = bookTitles.OrderBy(x => x.getTitle()).ToList();

foreach (Book z in sortedList) {

h += z.ToString ();

h += “n”;

}

return h;

}

public string ToStringAuthor()

{

string h = “”;

var sortedList = bookTitles.OrderBy(x => x.getAuthor()).ToList();

foreach (Book z in sortedList) {

h += z.ToString2 ();

h += “n”;

}

return h;

}

public string ToStringID()

{

string h = “”;

var sortedList = bookTitles.OrderBy(x => x.getID()).ToList();

foreach (Book z in sortedList) {

h += z.ToString2 ();

h += “n”;

}

return h;

}

public static int Search(string title)

{

for (int i=0; i<= bookTitles.Count – 1; i++)

{

if(title == bookTitles[i].ToString())

{

Console.WriteLine (bookTitles[i].ToString2());

return i;

}

}

return -1;

}

public static void RemoveBook(string title)

{

for (int i=0; i<= bookTitles.Count – 1; i++)

{

if(title == bookTitles[i].ToString())

{

bookTitles.RemoveAt (i);

}

}

}

public static int GetBookCount()

{

return bookTitles.Count;

}

}

public class Book

{

private string title;

private string author;

private int ID;

public Book(string a, string b, int c)

{

title = a;

author = b;

ID = c;

}

public string getTitle() {

return title;

}

public string getAuthor() {

return author;

}

public int getID() {

return ID;

}

public override string ToString()

{

return title;

}

public string ToString2()

{

return title + ” by ” + author + ” with ID ” + ID;

}

}

}

Sample Run

Select one of the following:

 A  to add a book to the library
 S  to search for a book by title
 D  to display the contents of the library, alphabetically  by title 
 E  to display the contents of the library, alphabetically  by author 
 F  to display the contents of the library, in ascending order by id num 
 R  to remove a book from the library
 Q  to quit this program


enter choice here:  A
Please insert a title for the new book.
 Harry Potter
Please insert an author for the new book.
 Rowling
Book successfully added!

Select one of the following:

 A  to add a book to the library
 S  to search for a book by title
 D  to display the contents of the library, alphabetically  by title 
 E  to display the contents of the library, alphabetically  by author 
 F  to display the contents of the library, in ascending order by id num 
 R  to remove a book from the library
 Q  to quit this program


enter choice here:  S
Please type a book title to search: 
 Harry Potter
Harry Potter by Rowling with ID 6

Select one of the following:

 A  to add a book to the library
 S  to search for a book by title
 D  to display the contents of the library, alphabetically  by title 
 E  to display the contents of the library, alphabetically  by author 
 F  to display the contents of the library, in ascending order by id num 
 R  to remove a book from the library
 Q  to quit this program


enter choice here:  D
C# programming
C++ programming
graphics & multimedia
Harry Potter
java programming
unity programming


Select one of the following:

 A  to add a book to the library
 S  to search for a book by title
 D  to display the contents of the library, alphabetically  by title 
 E  to display the contents of the library, alphabetically  by author 
 F  to display the contents of the library, in ascending order by id num 
 R  to remove a book from the library
 Q  to quit this program


enter choice here:  E
graphics & multimedia by Chastine with ID 5
C++ programming by Franklin with ID 1
C# programming by Gesick with ID 4
unity programming by Preston with ID 3
java programming by Roth with ID 2
Harry Potter by Rowling with ID 6


Select one of the following:

 A  to add a book to the library
 S  to search for a book by title
 D  to display the contents of the library, alphabetically  by title 
 E  to display the contents of the library, alphabetically  by author 
 F  to display the contents of the library, in ascending order by id num 
 R  to remove a book from the library
 Q  to quit this program


enter choice here:  F
C++ programming by Franklin with ID 1
java programming by Roth with ID 2
unity programming by Preston with ID 3
C# programming by Gesick with ID 4
graphics & multimedia by Chastine with ID 5
Harry Potter by Rowling with ID 6


Select one of the following:

 A  to add a book to the library
 S  to search for a book by title
 D  to display the contents of the library, alphabetically  by title 
 E  to display the contents of the library, alphabetically  by author 
 F  to display the contents of the library, in ascending order by id num 
 R  to remove a book from the library
 Q  to quit this program


enter choice here:  R
Please type a book title to remove: 
 Harry Potter
Book successfully removed!

Select one of the following:

 A  to add a book to the library
 S  to search for a book by title
 D  to display the contents of the library, alphabetically  by title 
 E  to display the contents of the library, alphabetically  by author 
 F  to display the contents of the library, in ascending order by id num 
 R  to remove a book from the library
 Q  to quit this program


enter choice here:  D
C# programming
C++ programming
graphics & multimedia
java programming
unity programming


Select one of the following:

 A  to add a book to the library
 S  to search for a book by title
 D  to display the contents of the library, alphabetically  by title 
 E  to display the contents of the library, alphabetically  by author 
 F  to display the contents of the library, in ascending order by id num 
 R  to remove a book from the library
 Q  to quit this program


enter choice here:  Q
good bye

Homework Ocean
Calculate your paper price
Pages (550 words)
Approximate price: -

Why Work with Us

Top Quality and Well-Researched Papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

Professional and Experienced Academic Writers

We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

Essays

Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.

Admissions

Admission Essays & Business Writing Help

An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.

Reviews

Editing Support

Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.

Reviews

Revision Support

If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.

× Contact Live Agents