C
Join ServerC#
help
Library console application
FFaraj10/23/2022
Faraj — Today at 2:45 PM
I'm building this project consisting of a library app that borrows & returns books, very simple. I've been with this for 3 days and now I gave up. I decided to ask using thread instead. I'm trying to implement 2 functions that enable the user to borrow and return books. So the user should only enter a book name/ title for example "Harry Potter" and the book should be displayed followed by the rest of the information. Any hints? https://paste.mod.gg/mlprnnmurnpu/1
I'm building this project consisting of a library app that borrows & returns books, very simple. I've been with this for 3 days and now I gave up. I decided to ask using thread instead. I'm trying to implement 2 functions that enable the user to borrow and return books. So the user should only enter a book name/ title for example "Harry Potter" and the book should be displayed followed by the rest of the information. Any hints? https://paste.mod.gg/mlprnnmurnpu/1
SSteak10/23/2022
so do you want user just input book Title and get the book details?
FFaraj10/23/2022
Exactly
FFaraj10/23/2022
I am so tired of this man
FFaraj10/23/2022
supposedly it should look like this
FFaraj10/23/2022
To borrow a book Remove a book from LibraryBooks Add it to a list called myBooks
To return a book Remove a book from a list called myBooks Add a book to Library Books
To return a book Remove a book from a list called myBooks Add a book to Library Books
SSteak10/23/2022
ok, i've got the idea
SSteak10/23/2022
so what's the main concern here?
FFaraj10/23/2022
Well! I'm bad at writing logic. I've made a dictionary for the books and a user inputs + a list for the borrowed books
FFaraj10/23/2022
But I don't how to connect the all together
FFaraj10/23/2022
Basically, I need to write a logic where I could add and remove books between the dictionary and the list
FFaraj10/23/2022
A user wants to borrow a book like Harry Potter, remove it from the dictionary and add it to a myBooks list, and the opposite when returning
FFaraj10/23/2022
Do you think this a wrong way of building the project?
SSteak10/23/2022
after looking your code, u can just use a List rather than a dictionary
SSteak10/23/2022
may I know why were u using dictionary?
SSteak10/23/2022
my first suggestion is create a function to iterate a list if that book is exist by getting title parameter
SSteak10/23/2022
like TryGetBook(title, out BookClass book)
FFaraj10/23/2022
Well! I choose a dictionary just for the practicing sake. I want to learn how to use it.
SSteak10/23/2022
oh ok all good, but for your case dictionary wont be neccessary, you can use book.id as the key
FFaraj10/23/2022
Ok! So if I use the book.id as the key, could I keep the dictionary or should I change it to a list?
SSteak10/23/2022
list
SSteak10/23/2022
this
SSteak10/23/2022
u can use like this
SSteak10/23/2022
or u can split into two
SSteak10/23/2022
IsBookExist (return bool), GetBook(string title) return a Book obj
FFaraj10/23/2022
Ok! I haven't used this kind of code before 😆 but I can give it a try.
SSteak10/23/2022
splitting your function is good for long term
FFaraj10/23/2022
Ok! Which function do I need to split?
SSteak10/23/2022
.