-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
119 lines (94 loc) · 3.47 KB
/
Copy pathProgram.cs
File metadata and controls
119 lines (94 loc) · 3.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace practice
{
class Program
{
static void Main(string[] args)
{
}
}
[Serializable]
public class Book
{
public string Title { get; set; }
public string Author { get; set; }
public int ISBN { get; set; }
public string Genre { get; set; }
public int YearPublished { get; set; }
}
//why won't Book turn blue????
public class CardCatalog : Book
{
private string _filename { get; set; }
//we have to do something with this code
private List<Book> books = new List<Book>() { };
public CardCatalog(string filename)
{
_filename = filename;
}
// static List<string> movieTitles = new List<string>();
static void optionMenu()
{
}
public void ListBooks(Book addMoreBooks = null)
{
List<Book> bookList = new List<Book>()
{
new Book{Title = "Rosemary's Baby", Author = "Ira Levin", Genre = "Horror" },
new Book{Title = "50 Shades of Grey", Author = "E.L.Green", Genre = "Erotica"},
new Book{Title = "Harry Potter", Author = "J.K. Rowling", Genre = "Young Adult"},
new Book{Title = "Salem's Lot", Author = "Stephen King", Genre = "Horror"},
new Book{Title = "Percy Jackson", Author = "Rick Riordan", Genre = "Young Adult" },
};
if (addMoreBooks == null)
{
}
else
{
Console.WriteLine(books);
}
var alphabetizedBooks = from allbooks in bookList
orderby allbooks.Title ascending
select allbooks;
foreach (var item in alphabetizedBooks)
{
Console.WriteLine("{0} written by {1}", item.Title, item.Author);
}
}
public void AddBook()
{
string bookTitle = "";
string bookAuthor = "";
string bookGenre = "";
Console.WriteLine("Please enter a Title: ");
bookTitle = Console.ReadLine();
Console.WriteLine("Please enter an Author: ");
bookAuthor = Console.ReadLine();
Console.WriteLine("Please enter a genre: ");
bookGenre = Console.ReadLine();
Book newBook = new Book { Title = bookTitle, Author = bookAuthor, Genre = bookGenre };
books.Add(newBook);
}
public void Save()
{
/*
XmlSerializer xs = new XmlSerializer(typeof(CardCatalog));
Stream stream = File.OpenWrite(_filename);
xs.Serialize(stream, books);
stream.Close();
stream.Dispose();
*/
//serialize with binary
/*
IFormatter formatter = new BinaryFormatter();
Stream stream = new FileStream(_filename, FileMode.Create, FileAccess.Write, FileShare.None);
formatter.Serialize(stream, this.books);
stream.Close();
stream.Dispose();
*/
}
}
}