public void TakeBook(ref List <Book.Book> Books) { Console.Write("Введите номер книги, которую хотите взять: "); try { int bookNumber = Int32.Parse(Console.ReadLine()); if (Books.Any(w => w.bookid == bookNumber) && Books.FirstOrDefault(w => w.bookid == bookNumber).status == false) { int idx = Books.IndexOf(Books.FirstOrDefault(w => w.bookid == bookNumber)); Book.Book book = Books[idx]; book.status = true; Books[idx] = book; takenBooks.Add(book); } else { Console.WriteLine("Такой книги нет или её невозможно взять."); } } catch (Exception) { Console.WriteLine("Неверный ввод"); } }
static void Main(string[] args) { Book book1 = new Book(); //最初のBookはvarでもいい book1.title = "C#入門"; book1.publishedDate = new DateTime(2000,11,11); book1.author = "七月太郎"; book1.price = 1000; int taxIncludedPrice = book1.getTaxIncludedPrice(); int tax = book1.getTax(); Console.WriteLine(tax + " " + taxIncludedPrice); Console.WriteLine(book1.title); Console.WriteLine(book1.author); Magazine mag1 = new Magazine(); mag1.title = "ベーシックマガジン"; mag1.price = 1000; mag1.month = 1; int taxInclujdedPrice = mag1.getTaxIncludedPrice(); string monthStr = mag1.getMonth(); Novel nov1 = new Novel(); nov1.title = "のー"; nov1.series = "赤"; Console.WriteLine(tax + " " + taxIncludedPrice); Console.WriteLine(mag1.title); Console.WriteLine(mag1.author); Console.WriteLine(tax + " " + taxIncludedPrice); Console.WriteLine(nov1.title); Console.WriteLine(nov1.author); }
public List <Book.Book> ReadFile(List <Book.Book> books) { List <Book.Book> bks = books; try { this.reader = new StreamReader(@"C:\Users\Samantha\source\repos\Assignment_01_PRO670\Assignment_01_PRO670\" + this.fileName); } catch (Exception e) { Console.WriteLine(e); } using (reader) { while (!reader.EndOfStream) { Book.Book tempBook = new Book.Book(); var line = reader.ReadLine(); var values = line.Split(','); tempBook.BookId = Int16.Parse(values[0]); tempBook.LibraryId = Int16.Parse(values[1]); tempBook.Title = values[2]; tempBook.Summary = values[3]; bks.Add(tempBook); } } return(bks); }
public static void Display(Book.Book BookRef) { Console.WriteLine("Title: {0}", BookRef.Title); Console.WriteLine("Author Last Name: {0}", BookRef.AuthorLName); Console.WriteLine("Author First Name: {0}", BookRef.AuthorFName); Console.WriteLine("Category: {0}", BookRef.Category); Console.WriteLine("Location: {0}", BookRef.Location); Console.WriteLine("ISBN: {0}", BookRef.ISBN); Console.WriteLine("Press enter to view another book"); Console.ReadLine(); }
// Prompts user to add book to library public void AddBook(List <Library.Library> libraries, List <Book.Book> books) { int index = SelectLibrary(libraries); if (index == -1) { throw new CustomErrors.BookNotFoundException("ERROR: Library not found. Returning to main menu. \n"); } Book.Book bookTemp = libraries[index].AddBook(); books.Add(bookTemp); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("SUCCESS: Book added to library."); }
// Prompts user to update book from library public void UpdateBook(List <Library.Library> libraries, List <Book.Book> books) { int index = SelectLibrary(libraries); if (index == -1) { throw new CustomErrors.BookNotFoundException("ERROR: Library not found. Returning to main menu. \n"); } Book.Book tempBook = libraries[index].UpdateBook(); int bookIndex = books.FindIndex(b => b.BookId.ToString() == tempBook.BookId.ToString()); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("SUCCESS: Book has been updated."); }
public static void NewBook(Book.Book currentBook) { Console.WriteLine("Please enter the title of the book"); currentBook.Title = Console.ReadLine(); Console.WriteLine("Please enter the Last name of the author"); currentBook.AuthorLName = Console.ReadLine(); Console.WriteLine("Please enter the First name of the author"); currentBook.AuthorFName = Console.ReadLine(); Console.WriteLine("Please enter the Category of the book"); currentBook.Category = Console.ReadLine(); Console.WriteLine("Please enter the Location of the book"); currentBook.Location = Console.ReadLine(); Console.WriteLine("Please enter the ISBN of the book"); currentBook.ISBN = double.Parse(Console.ReadLine()); Console.WriteLine("Press enter to return to the menu"); string choice = Console.ReadLine(); }
static void Main(string[] args) { var book1 = new Book(); book1.title = "C#入門"; book1.publishedDate = new DateTime(2000, 12, 31); book1.author = "七月太郎"; book1.price = 1000; int taxIncludedPrice = book1.getTaxIncludedPrice(); int tax = book1.getTax(); Console.WriteLine(tax + " " + taxIncludedPrice); Console.WriteLine(book1.title); Console.WriteLine(book1.author); var p1 = new Person(); p1.lastName = "田中"; p1.firstName = "太郎"; p1.furiganaLastName = "たなか"; p1.furiganaFirstName = "たろう"; p1.birthday = new DateTime(2009, 1, 1); Console.Write(p1.lastName + " " + p1.firstName); Console.Write("(" + p1.furiganaLastName + " " + p1.furiganaFirstName + ")、"); Console.WriteLine(p1.birthday.Year + "/" + p1.birthday.Month + "/" + p1.birthday.Day + "生 " + p1.getAge() + "才"); var p2 = new Person(); p2.lastName = "鈴木"; p2.firstName = "花子"; p2.furiganaLastName = "すずき"; p2.furiganaFirstName = "はなこ"; p2.birthday = new DateTime(1998, 12, 31); Console.Write(p2.lastName + " " + p2.firstName); Console.Write("(" + p2.furiganaLastName + " " + p2.furiganaFirstName + ")、"); Console.WriteLine(p2.birthday.Year + "/" + p2.birthday.Month + "/" + p2.birthday.Day + "生 " + p2.getAge() + "才"); }
// Prompt user to add book to library public Book.Book AddBook() { // Add init values for new book Book.Book bookTemp = new Book.Book(); bookTemp.BookId = (this.books.Count) + 1; bookTemp.Library = this; bookTemp.LibraryId = this.LibraryId; // Prompt User to add book details Console.WriteLine("Add a book by adding the following details (press enter to go onto next question): "); Console.Write("Enter book title: "); bookTemp.Title = Console.ReadLine(); Console.Write("Enter book summary: "); bookTemp.Summary = Console.ReadLine(); // Add books to book list and corresponding library bookTemp.Library += bookTemp; return(bookTemp); }
static void Main(string[] args) { Book book1 = new Book("Three on the boat, exclude the Dog", "Jerome K. Jerome", "Awesome comedy story"); book1.Show(); Console.ReadKey(); }
static void Main(string[] args) { var book1 = new Book(); book1.title = "C#入門"; book1.publishedDate = new DateTime(2000, 12, 31); book1.author = "七月太郎"; book1.Price = -1; var book2 = new Book("C#大好き", "七月太郎", new DateTime(2015, 7, 1), 2000); Magazine mag1 = new Magazine(); mag1.title = "ベーシックマガジン"; mag1.Price = 1000; mag1.month = 1; int taxIncludedPrice = mag1.getTaxIncludedPrice(); int tax = mag1.getTax(); Console.WriteLine("税抜価格 " + book1.Price + " "); Console.WriteLine(tax + " " + taxIncludedPrice); Console.WriteLine(mag1.title + mag1.getMonth()); Console.WriteLine(mag1.author); Novel nov1 = new Novel(); nov1.title = "no c#, no life"; nov1.series = "xxx文庫"; var p1 = new Person(); p1.lastName = "田中"; p1.firstName = "太郎"; p1.furiganaLastName = "たなか"; p1.furiganaFirstName = "たろう"; p1.birthday = new DateTime(2009, 1, 1); Console.Write(p1.lastName + " " + p1.firstName); Console.Write("(" + p1.furiganaLastName + " " + p1.furiganaFirstName + ")、"); Console.WriteLine(p1.birthday.Year + "/" + p1.birthday.Month + "/" + p1.birthday.Day + "生 " + p1.getAge() + "才"); var p2 = new Person(); p2.lastName = "鈴木"; p2.firstName = "花子"; p2.furiganaLastName = "すずき"; p2.furiganaFirstName = "はなこ"; p2.birthday = new DateTime(1998, 12, 31); p2.Height = 180.3; p2.Weight = 90.5; Console.Write(p2.lastName + " " + p2.firstName); Console.Write("(" + p2.furiganaLastName + " " + p2.furiganaFirstName + ")、"); Console.WriteLine(p2.birthday.Year + "/" + p2.birthday.Month + "/" + p2.birthday.Day + "生 " + p2.getAge() + "才"); Console.WriteLine(p2.Height + "cm " + p2.Weight + "kg"); var s1 = new Student(); s1.lastName = "伊藤"; s1.firstName = "四朗"; s1.id = "aaa"; s1.grade = 1; s1.scores = new Dictionary<string, int>(); s1.scores["国語"] = 100; s1.scores["英語"] = 50; Console.Write(s1.lastName + " " + s1.firstName); Console.WriteLine("合計点:" + s1.getTotalScore()); }
// Removes book from library public void RemoveBook(Book.Book book) { int bookIndex = books.FindIndex(b => b.BookId.ToString() == book.BookId.ToString()); books.RemoveAt(bookIndex); }
// Adds book to library public void AddBook(Book.Book book) { this.books.Add(book); }