From a317c455c3aa4e88618012fab395245d2c5e0b5b Mon Sep 17 00:00:00 2001
From: "github-classroom[bot]"
<66690702+github-classroom[bot]@users.noreply.github.com>
Date: Mon, 6 Apr 2026 16:08:14 +0000
Subject: [PATCH 1/6] Setting up GitHub Classroom Feedback
From 0302a3d8dc9f8231e4816c30c2aa03c43f835047 Mon Sep 17 00:00:00 2001
From: kingbugbux <149598271+kingbugbux@users.noreply.github.com>
Date: Sun, 19 Apr 2026 21:31:53 -0400
Subject: [PATCH 2/6] added the skeleton for all of the classes
---
.../LibraryApp/Library.cs | 12 ----
.../LibraryApp/LibraryAdminPage.xaml | 7 ++-
.../LibraryApp/LibraryAdminPage.xaml.cs | 10 ++++
.../LibraryApp/LibraryApp.csproj | 14 ++---
.../LibraryApp/LibraryBrowsePage.xaml | 11 ++--
.../LibraryApp/LibraryBrowsePage.xaml.cs | 15 +++++
.../LibraryApp/businesslogic/Book.cs | 55 +++++++++++++++++++
.../LibraryApp/businesslogic/Library.cs | 48 ++++++++++++++++
.../LibraryApp/businesslogic/assetstatus.cs | 14 +++++
.../LibraryApp/businesslogic/booktype.cs | 12 ++++
.../LibraryApp/businesslogic/digitalbook.cs | 26 +++++++++
.../LibraryApp/businesslogic/libraryassist.cs | 20 +++++++
.../LibraryApp/businesslogic/loanperiod.cs | 26 +++++++++
.../LibraryApp/businesslogic/paperbook.cs | 25 +++++++++
14 files changed, 269 insertions(+), 26 deletions(-)
delete mode 100644 LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/Library.cs
create mode 100644 LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Book.cs
create mode 100644 LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Library.cs
create mode 100644 LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/assetstatus.cs
create mode 100644 LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/booktype.cs
create mode 100644 LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/digitalbook.cs
create mode 100644 LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/libraryassist.cs
create mode 100644 LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/loanperiod.cs
create mode 100644 LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/paperbook.cs
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/Library.cs b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/Library.cs
deleted file mode 100644
index 172f11d..0000000
--- a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/Library.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-namespace LibraryAppInteractive;
-
-///
-/// Defines the Library class used to manage the library books and assets.
-///
-/// NOTE: A single object/instance of this class (called a "singleton") is created and shared automatically
-/// with the two pages in the application through the process of Dependency Injection handled and configured
-/// in MauiProgram class.
-///
-public class Library
-{
-}
\ No newline at end of file
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryAdminPage.xaml b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryAdminPage.xaml
index 416d3ce..2b9825e 100644
--- a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryAdminPage.xaml
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryAdminPage.xaml
@@ -5,8 +5,9 @@
x:Class="LibraryAppInteractive.LibraryAdminPage"
Title="Manage Book Assets">
-
+
+
+
+
\ No newline at end of file
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryAdminPage.xaml.cs b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryAdminPage.xaml.cs
index c9c0b9c..2799d5e 100644
--- a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryAdminPage.xaml.cs
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryAdminPage.xaml.cs
@@ -12,4 +12,14 @@ public LibraryAdminPage()
{
InitializeComponent();
}
+
+ private void RegisterBook(object sender, EventArgs e)
+ {
+
+ }
+
+ private void DisplayBook(object sender, EventArgs e)
+ {
+
+ }
}
\ No newline at end of file
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryApp.csproj b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryApp.csproj
index 2d4bcbc..d7fa65d 100644
--- a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryApp.csproj
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryApp.csproj
@@ -35,21 +35,21 @@
-
+
-
+
-
-
-
+
+
+
-
+
-
+
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryBrowsePage.xaml b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryBrowsePage.xaml
index 91c0947..b22eb24 100644
--- a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryBrowsePage.xaml
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryBrowsePage.xaml
@@ -3,8 +3,11 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="LibraryAppInteractive.LibraryBrowsePage"
Title="Browse Interactive Library">
-
-
+
+
+
+
+
+
+
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryBrowsePage.xaml.cs b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryBrowsePage.xaml.cs
index 2e8fc26..1979438 100644
--- a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryBrowsePage.xaml.cs
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryBrowsePage.xaml.cs
@@ -6,4 +6,19 @@ public LibraryBrowsePage()
{
InitializeComponent();
}
+
+ private void SearchBook(object sender, EventArgs e)
+ {
+
+ }
+
+ private void BorrowBook(object sender, EventArgs e)
+ {
+
+ }
+
+ private void OnReturnBook(object sender, EventArgs e)
+ {
+
+ }
}
\ No newline at end of file
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Book.cs b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Book.cs
new file mode 100644
index 0000000..f8e46e0
--- /dev/null
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Book.cs
@@ -0,0 +1,55 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace LibraryAppInteractive.businesslogic;
+
+public class Book
+{
+ protected string _bookName;
+ protected string _bookISBN;
+ protected List _bookAuthorList;
+ protected List _libAssetList;
+
+ public string Name { get; set; }
+ public string ISBN { get; set; }
+ public List Authors { get; set; }
+ public IEnumerable Assets { get; }
+
+ public Book(string bookName, string bookISBN) { }
+
+ public virtual bool CheckAvailability()
+ {
+ return false;
+ }
+
+ public virtual LibraryAsset BorrowBook()
+ {
+ return null;
+ }
+
+ public virtual (TimeSpan, int, decimal) ReturnBook(int libID)
+ {
+ return (TimeSpan.Zero, 0, 0);
+ }
+
+ public virtual LibraryAsset ReserveBook()
+ {
+ return null;
+ }
+
+ public LibraryAsset findLibraryAsset(int libID)
+ {
+ return null;
+ }
+
+ public LibraryAsset findNextAvailableAsset()
+ {
+ return null;
+ }
+
+ public void AddAsset(LibraryAsset asset)
+ {
+
+ }
+}
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Library.cs b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Library.cs
new file mode 100644
index 0000000..14e3993
--- /dev/null
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Library.cs
@@ -0,0 +1,48 @@
+namespace LibraryAppInteractive.businesslogic;
+
+///
+/// Defines the Library class used to manage the library books and assets.
+///
+/// NOTE: A single object/instance of this class (called a "singleton") is created and shared automatically
+/// with the two pages in the application through the process of Dependency Injection handled and configured
+/// in MauiProgram class.
+///
+public class Library
+{
+ private List _bookList;
+ private int _libraryIdGeneratorSeed;
+ private const int DEFAULT_LIBID_START = 100;
+
+ public Library()
+ {
+ }
+
+ private int GenerateLibId()
+ {
+ return 0;
+ }
+
+ public void CreateDefaultBooks()
+ {
+ }
+
+ public int DetermineLibId()
+ {
+ return 0;
+ }
+
+ public Book RegisterBook(string bookName, string bookISBN, string[] authors, BookType bookType, int nCopies)
+ {
+ return null;
+ }
+
+ public Book FindBookByName(string bookName)
+ {
+ return null;
+ }
+
+ public Book FindBookByISBN(string bookISBN)
+ {
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/assetstatus.cs b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/assetstatus.cs
new file mode 100644
index 0000000..f8defe2
--- /dev/null
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/assetstatus.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace LibraryAppInteractive.businesslogic;
+ public enum AssetStatus
+ {
+ Notavailable,
+ Available,
+ Loaned,
+ Reserved
+
+ }
+
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/booktype.cs b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/booktype.cs
new file mode 100644
index 0000000..791b9a4
--- /dev/null
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/booktype.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace LibraryAppInteractive.businesslogic;
+ public enum BookType
+ {
+ paper = 1,
+ Digital,
+ Audio
+ }
+
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/digitalbook.cs b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/digitalbook.cs
new file mode 100644
index 0000000..dd79ccd
--- /dev/null
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/digitalbook.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace LibraryAppInteractive.businesslogic;
+
+public class DigitalBook : Book
+{
+ private int _maxBorrowDays;
+ private float _latePenaltyPerDay;
+
+ public DigitalBook(string bookName, string bookISBN)
+ : base(bookName, bookISBN) { }
+
+ public void DetermineLoanLicense() { }
+
+ public override LibraryAsset BorrowBook()
+ {
+ return null;
+ }
+
+ public override (TimeSpan, int, decimal) ReturnBook(int libID)
+ {
+ return (TimeSpan.Zero, 0, 0);
+ }
+}
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/libraryassist.cs b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/libraryassist.cs
new file mode 100644
index 0000000..06b6736
--- /dev/null
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/libraryassist.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace LibraryAppInteractive.businesslogic;
+
+public class LibraryAsset
+{
+ private Book _book;
+ private int _libID;
+ private AssetStatus _status;
+ private LoanPeriod _loanPeriod;
+
+ public AssetStatus Status { get; set; }
+ public LoanPeriod Loan { get; set; }
+ public bool IsAvailable { get; }
+
+ public LibraryAsset(int libID, Book book) { }
+}
+
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/loanperiod.cs b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/loanperiod.cs
new file mode 100644
index 0000000..78aa166
--- /dev/null
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/loanperiod.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace LibraryAppInteractive.businesslogic;
+
+public struct LoanPeriod
+{
+ private DateTime _borrowedOn;
+ private DateTime _returnedOn;
+ private DateTime _dueDate;
+
+ public DateTime BorrowedOn { get; }
+ public DateTime ReturnedOn { get; }
+ public DateTime DueDate { get; }
+ public TimeSpan LoanDuration { get; }
+ public TimeSpan LatePeriod { get; }
+
+ public LoanPeriod(DateTime borrowedOn, DateTime returnedOn)
+ {
+
+
+
+ }
+}
+
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/paperbook.cs b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/paperbook.cs
new file mode 100644
index 0000000..18b8ddb
--- /dev/null
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/paperbook.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace LibraryAppInteractive.businesslogic;
+
+public class PaperBook : Book
+{
+ private const int _MAX_BORROW_DAYS = 30;
+ private const float _LATE_PENALTY_PER_DAY = 0.25f;
+
+ public PaperBook(string bookName, string bookISBN)
+ : base(bookName, bookISBN) { }
+
+ public override LibraryAsset BorrowBook()
+ {
+ return null;
+ }
+
+ public override (TimeSpan, int, decimal) ReturnBook(int libID)
+ {
+ return (TimeSpan.Zero, 0, 0);
+ }
+}
+
From a9298c508899b52537413d3a93f6f108969b6efc Mon Sep 17 00:00:00 2001
From: kingbugbux <149598271+kingbugbux@users.noreply.github.com>
Date: Sun, 19 Apr 2026 22:48:43 -0400
Subject: [PATCH 3/6] added the method of registering the book in library and
added most of the logic for book
---
.../LibraryApp/businesslogic/Book.cs | 55 ++++++++++++++++++-
.../LibraryApp/businesslogic/Library.cs | 34 +++++++++++-
.../LibraryApp/businesslogic/booktype.cs | 2 +-
.../{libraryassist.cs => libraryasset.cs} | 9 ++-
4 files changed, 92 insertions(+), 8 deletions(-)
rename LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/{libraryassist.cs => libraryasset.cs} (68%)
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Book.cs b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Book.cs
index f8e46e0..02806a9 100644
--- a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Book.cs
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Book.cs
@@ -16,21 +16,65 @@ public class Book
public List Authors { get; set; }
public IEnumerable Assets { get; }
- public Book(string bookName, string bookISBN) { }
+ public Book(string bookName, string bookISBN)
+ {
+
+ }
public virtual bool CheckAvailability()
{
+ if (_libAssetList.Count == 0)
+ {
+ return false;
+ }
+ foreach (var asset in _libAssetList)
+ {
+ if (asset.Status == AssetStatus.Available)
+ {
+ return true;
+ }
+ }
return false;
}
public virtual LibraryAsset BorrowBook()
{
+ foreach (var asset in _libAssetList)
+ {
+ if (asset.Status == AssetStatus.Available)
+ {
+ asset.Status = AssetStatus.Loaned;
+ //used google to find the information on the datetime command
+ asset.Loan = new LoanPeriod(DateTime.Now, DateTime.MinValue);
+ return asset;
+ }
+ }
+
return null;
}
public virtual (TimeSpan, int, decimal) ReturnBook(int libID)
{
- return (TimeSpan.Zero, 0, 0);
+ var asset = findLibraryAsset(libID);
+ if (asset == null)
+ {
+ return (TimeSpan.Zero, 0, 0);
+ }
+
+ if (asset.Status != AssetStatus.Loaned)
+ {
+ return (TimeSpan.Zero, 0, 0);
+ }
+
+ DateTime returnTime = DateTime.Now;
+ asset.Loan = new LoanPeriod(asset.Loan.BorrowedOn, returnTime);
+ asset.Status = AssetStatus.Available;
+ TimeSpan durationLoaned = asset.Loan.LoanDuration;
+
+ int daysLate = asset.Loan.LatePeriod.Days;
+ decimal penaltyFee = 0;
+
+ return (durationLoaned, daysLate,penaltyFee);
}
public virtual LibraryAsset ReserveBook()
@@ -40,6 +84,13 @@ public virtual LibraryAsset ReserveBook()
public LibraryAsset findLibraryAsset(int libID)
{
+ foreach (var asset in _libAssetList)
+ {
+ if (asset._libID == libID)
+ {
+ return asset;
+ }
+ }
return null;
}
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Library.cs b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Library.cs
index 14e3993..c80df23 100644
--- a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Library.cs
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Library.cs
@@ -11,10 +11,12 @@ public class Library
{
private List _bookList;
private int _libraryIdGeneratorSeed;
- private const int DEFAULT_LIBID_START = 100;
+ private const int default_libid_start = 100;
public Library()
{
+ _bookList = new List();
+ _libraryIdGeneratorSeed = default_libid_start;
}
private int GenerateLibId()
@@ -24,16 +26,42 @@ private int GenerateLibId()
public void CreateDefaultBooks()
{
+
}
public int DetermineLibId()
{
- return 0;
+ return _libraryIdGeneratorSeed++;
}
public Book RegisterBook(string bookName, string bookISBN, string[] authors, BookType bookType, int nCopies)
{
- return null;
+ Book newbook;
+ switch (bookType)
+ {
+ case BookType.Paper:
+ newbook = new PaperBook(bookName, bookISBN);
+ break;
+
+ case BookType.Digital:
+ newbook = new DigitalBook(bookName, bookISBN);
+ break;
+
+ default:
+ throw new Exception("not a valid book");
+ }
+ newbook.Authors = authors.ToList();
+
+ for (int i = 0; i < nCopies; i++)
+ {
+ int id = DetermineLibId();
+ LibraryAsset asset = new LibraryAsset(id, newbook);
+
+ newbook.AddAsset(asset);
+ }
+ _bookList.Add(newbook);
+
+ return newbook;
}
public Book FindBookByName(string bookName)
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/booktype.cs b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/booktype.cs
index 791b9a4..7b4fa71 100644
--- a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/booktype.cs
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/booktype.cs
@@ -5,7 +5,7 @@
namespace LibraryAppInteractive.businesslogic;
public enum BookType
{
- paper = 1,
+ Paper = 1,
Digital,
Audio
}
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/libraryassist.cs b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/libraryasset.cs
similarity index 68%
rename from LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/libraryassist.cs
rename to LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/libraryasset.cs
index 06b6736..c112ff6 100644
--- a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/libraryassist.cs
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/libraryasset.cs
@@ -7,7 +7,7 @@ namespace LibraryAppInteractive.businesslogic;
public class LibraryAsset
{
private Book _book;
- private int _libID;
+ public int _libID;
private AssetStatus _status;
private LoanPeriod _loanPeriod;
@@ -15,6 +15,11 @@ public class LibraryAsset
public LoanPeriod Loan { get; set; }
public bool IsAvailable { get; }
- public LibraryAsset(int libID, Book book) { }
+ public LibraryAsset(int libID, Book book)
+ {
+ _libID = libID;
+ _book = book;
+ _status = AssetStatus.Available;
+ }
}
From 2c62ccd51f65d8af65fa1571786f67ce8675ff04 Mon Sep 17 00:00:00 2001
From: kingbugbux <149598271+kingbugbux@users.noreply.github.com>
Date: Mon, 20 Apr 2026 00:32:23 -0400
Subject: [PATCH 4/6] added more methods for book library and loan period and
added some working parts ofr the ui in browser page and fixed a very
annoyying bug that took like a hour to fix
---
.../LibraryApp/LibraryAdminPage.xaml | 4 +-
.../LibraryApp/LibraryBrowsePage.xaml | 10 +--
.../LibraryApp/LibraryBrowsePage.xaml.cs | 66 +++++++++++++++++--
.../LibraryApp/MauiProgram.cs | 8 ++-
.../LibraryApp/businesslogic/Book.cs | 42 +++++++++---
.../LibraryApp/businesslogic/Library.cs | 23 +++++++
.../LibraryApp/businesslogic/loanperiod.cs | 48 +++++++++++---
7 files changed, 171 insertions(+), 30 deletions(-)
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryAdminPage.xaml b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryAdminPage.xaml
index 2b9825e..4f69272 100644
--- a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryAdminPage.xaml
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryAdminPage.xaml
@@ -6,8 +6,8 @@
Title="Manage Book Assets">
-
-
+
+
\ No newline at end of file
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryBrowsePage.xaml b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryBrowsePage.xaml
index b22eb24..52bc3eb 100644
--- a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryBrowsePage.xaml
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryBrowsePage.xaml
@@ -5,9 +5,11 @@
Title="Browse Interactive Library">
-
-
-
-
+
+
+
+
+
+
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryBrowsePage.xaml.cs b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryBrowsePage.xaml.cs
index 1979438..7fc42e6 100644
--- a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryBrowsePage.xaml.cs
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryBrowsePage.xaml.cs
@@ -1,24 +1,80 @@
-namespace LibraryAppInteractive;
+using LibraryAppInteractive.businesslogic;
+
+namespace LibraryAppInteractive;
public partial class LibraryBrowsePage : ContentPage
{
- public LibraryBrowsePage()
+ public Library _library;
+ public LibraryBrowsePage(Library library)
{
InitializeComponent();
+ _library = library;
+
}
- private void SearchBook(object sender, EventArgs e)
+ private async void SearchBook(object sender, EventArgs e)
{
+ if (_library == null)
+ {
+ await DisplayAlert("Error", "Library not initialized", "OK");
+ return;
+ }
+ string bookName = _txtbookname.Text;
+ Book book = _library.FindBookByName(bookName);
+ if (book == null)
+ {
+ await DisplayAlert("Not found","No book availble","Ok");
+ }
}
- private void BorrowBook(object sender, EventArgs e)
+ private async void BorrowBook(object sender, EventArgs e)
{
+ if (_library == null)
+ {
+ await DisplayAlert("Error", "Library not initialized", "OK");
+ return;
+ }
+ string isbn = _txtISBN.Text;
+ Book book = _library.FindBookByISBN(isbn);
+ if (book == null)
+ {
+ await DisplayAlert("Not found","No book found","Ok");
+
+ }
+
+ LibraryAsset asset = book.BorrowBook();
+ if (asset == null)
+ {
+ await DisplayAlert("Not found", "No copies found", "Ok");
+
+ }
}
- private void OnReturnBook(object sender, EventArgs e)
+ private async void OnReturnBook(object sender, EventArgs e)
{
+ if (_library == null)
+ {
+ await DisplayAlert("Error", "Library not initialized", "OK");
+ return;
+ }
+ string isbn = _txtISBN.Text;
+ if (!int.TryParse(_txtLibID.Text, out int libId))
+ {
+ await DisplayAlert("Error", "Please enter a valid numeric Library ID", "OK");
+ return;
+ }
+ int LibId = int.Parse(_txtLibID.Text);
+ Book book = _library.FindBookByISBN(isbn);
+
+ if (book == null)
+ {
+ await DisplayAlert("Not found", "No book found", "Ok");
+
+ }
+
+ var result = book.ReturnBook(LibId);
}
}
\ No newline at end of file
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/MauiProgram.cs b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/MauiProgram.cs
index 9fe3540..f8cb079 100644
--- a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/MauiProgram.cs
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/MauiProgram.cs
@@ -1,4 +1,5 @@
-using System.Collections.Immutable;
+using LibraryAppInteractive.businesslogic;
+using System.Collections.Immutable;
namespace LibraryAppInteractive;
@@ -14,7 +15,10 @@ public static MauiApp CreateMauiApp()
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});
-
+ builder.Services.AddSingleton();
+
+ builder.Services.AddTransient();
+ builder.Services.AddTransient();
return builder.Build();
}
}
\ No newline at end of file
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Book.cs b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Book.cs
index 02806a9..2a4daee 100644
--- a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Book.cs
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Book.cs
@@ -14,16 +14,25 @@ public class Book
public string Name { get; set; }
public string ISBN { get; set; }
public List Authors { get; set; }
- public IEnumerable Assets { get; }
+ public IEnumerable Assets
+ {
+ get
+ {
+ return _libAssetList;
+ }
+ }
public Book(string bookName, string bookISBN)
- {
-
+ {
+ Name = bookName;
+ ISBN = bookISBN;
+ _libAssetList = new List();
+ _bookAuthorList = new List();
}
public virtual bool CheckAvailability()
{
- if (_libAssetList.Count == 0)
+ if (_libAssetList.Count == 0 || _libAssetList == null)
{
return false;
}
@@ -45,7 +54,7 @@ public virtual LibraryAsset BorrowBook()
{
asset.Status = AssetStatus.Loaned;
//used google to find the information on the datetime command
- asset.Loan = new LoanPeriod(DateTime.Now, DateTime.MinValue);
+ asset.Loan = new LoanPeriod(DateTime.Now, DateTime.MinValue, 30);
return asset;
}
}
@@ -67,12 +76,13 @@ public virtual (TimeSpan, int, decimal) ReturnBook(int libID)
}
DateTime returnTime = DateTime.Now;
- asset.Loan = new LoanPeriod(asset.Loan.BorrowedOn, returnTime);
+ asset.Loan = new LoanPeriod(asset.Loan.BorrowedOn, returnTime, 30);
asset.Status = AssetStatus.Available;
TimeSpan durationLoaned = asset.Loan.LoanDuration;
int daysLate = asset.Loan.LatePeriod.Days;
- decimal penaltyFee = 0;
+ //googled how to make a decimal literal with m
+ decimal penaltyFee = daysLate * 0.5m;
return (durationLoaned, daysLate,penaltyFee);
}
@@ -96,11 +106,25 @@ public LibraryAsset findLibraryAsset(int libID)
public LibraryAsset findNextAvailableAsset()
{
+ if (_libAssetList == null)
+ {
+ return null;
+ }
+ foreach (var asset in _libAssetList)
+ {
+ if (asset.Status == AssetStatus.Available)
+ return asset;
+ }
+
return null;
}
public void AddAsset(LibraryAsset asset)
- {
-
+ {
+ if (_libAssetList == null)
+ {
+ _libAssetList = new List();
+ }
+ _libAssetList.Add(asset);
}
}
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Library.cs b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Library.cs
index c80df23..806eb0c 100644
--- a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Library.cs
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Library.cs
@@ -1,3 +1,4 @@
+
namespace LibraryAppInteractive.businesslogic;
///
@@ -66,11 +67,33 @@ public Book RegisterBook(string bookName, string bookISBN, string[] authors, Boo
public Book FindBookByName(string bookName)
{
+ if (_bookList == null)
+ {
+ return null;
+ }
+ foreach (Book book in _bookList)
+ {
+ if (book.Name != null && book.Name.Equals(bookName))
+ {
+ return book;
+ }
+ }
return null;
}
public Book FindBookByISBN(string bookISBN)
{
+ if (_bookList == null)
+ {
+ return null;
+ }
+ foreach (Book book in _bookList)
+ {
+ if (book.ISBN != null && book.ISBN == bookISBN)
+ {
+ return book;
+ }
+ }
return null;
}
}
\ No newline at end of file
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/loanperiod.cs b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/loanperiod.cs
index 78aa166..5d3bf45 100644
--- a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/loanperiod.cs
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/loanperiod.cs
@@ -10,15 +10,47 @@ public struct LoanPeriod
private DateTime _returnedOn;
private DateTime _dueDate;
- public DateTime BorrowedOn { get; }
- public DateTime ReturnedOn { get; }
- public DateTime DueDate { get; }
- public TimeSpan LoanDuration { get; }
- public TimeSpan LatePeriod { get; }
+ public DateTime BorrowedOn
+ {
+ get
+ {
+ return _borrowedOn;
+ }
+ }
+ public DateTime ReturnedOn {
+ get
+ { return _returnedOn;
+ }
+ }
+ public DateTime DueDate {
+ get
+ {
+ return _dueDate;
+ }
+ }
+ public TimeSpan LoanDuration {
+ get
+ {
+ return _returnedOn - _borrowedOn;
+ }
+ }
+ public TimeSpan LatePeriod {
+ get
+ {
+ if (_returnedOn <= _dueDate)
+ {
+ return TimeSpan.Zero;
+ }
- public LoanPeriod(DateTime borrowedOn, DateTime returnedOn)
- {
-
+ return _returnedOn - _dueDate;
+ }
+ }
+
+ public LoanPeriod(DateTime borrowedOn, DateTime returnedOn, int days)
+ {
+ _borrowedOn = borrowedOn;
+ _returnedOn = returnedOn;
+ _dueDate = borrowedOn.AddDays(days);
}
From 8cd1b9158a7a33f81f07c3a5454fb5fd7a35429d Mon Sep 17 00:00:00 2001
From: kingbugbux <149598271+kingbugbux@users.noreply.github.com>
Date: Mon, 20 Apr 2026 01:00:12 -0400
Subject: [PATCH 5/6] finished the methods on library and the two versions of
the books
---
.../LibraryApp/LibraryBrowsePage.xaml | 6 +--
.../LibraryApp/LibraryBrowsePage.xaml.cs | 4 ++
.../LibraryApp/businesslogic/Library.cs | 24 +++++++++++-
.../LibraryApp/businesslogic/digitalbook.cs | 39 +++++++++++++++++--
.../LibraryApp/businesslogic/paperbook.cs | 36 ++++++++++++++---
5 files changed, 95 insertions(+), 14 deletions(-)
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryBrowsePage.xaml b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryBrowsePage.xaml
index 52bc3eb..b5573ec 100644
--- a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryBrowsePage.xaml
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryBrowsePage.xaml
@@ -5,11 +5,11 @@
Title="Browse Interactive Library">
-
-
-
+
+
+
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryBrowsePage.xaml.cs b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryBrowsePage.xaml.cs
index 7fc42e6..7cdae77 100644
--- a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryBrowsePage.xaml.cs
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryBrowsePage.xaml.cs
@@ -9,6 +9,7 @@ public LibraryBrowsePage(Library library)
{
InitializeComponent();
_library = library;
+ _library.CreateDefaultBooks();
}
@@ -26,6 +27,7 @@ private async void SearchBook(object sender, EventArgs e)
{
await DisplayAlert("Not found","No book availble","Ok");
}
+ await DisplayAlert("Book found",$"Found the book {bookName}","Ok");
}
private async void BorrowBook(object sender, EventArgs e)
@@ -49,6 +51,7 @@ private async void BorrowBook(object sender, EventArgs e)
await DisplayAlert("Not found", "No copies found", "Ok");
}
+ await DisplayAlert("Book found", $"Borrowed the book {book.Name}", "Ok");
}
@@ -76,5 +79,6 @@ private async void OnReturnBook(object sender, EventArgs e)
var result = book.ReturnBook(LibId);
+ await DisplayAlert("Book returned",$"Returned the book {book.Name}","Ok");
}
}
\ No newline at end of file
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Library.cs b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Library.cs
index 806eb0c..dc6a477 100644
--- a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Library.cs
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Library.cs
@@ -22,12 +22,32 @@ public Library()
private int GenerateLibId()
{
- return 0;
+ return _libraryIdGeneratorSeed++;
}
public void CreateDefaultBooks()
{
-
+ RegisterBook(
+ "Book1",
+ "1234",
+ new string[] {"ME"},
+ BookType.Paper,
+ 4
+ );
+ RegisterBook(
+ "Book2",
+ "4567",
+ new string[] { "ME","MYSELF","I" },
+ BookType.Digital,
+ 1
+ );
+ RegisterBook(
+ "Book3",
+ "8976",
+ new string[] { "ME","YOU" },
+ BookType.Paper,
+ 2
+ );
}
public int DetermineLibId()
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/digitalbook.cs b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/digitalbook.cs
index dd79ccd..c3f66ee 100644
--- a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/digitalbook.cs
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/digitalbook.cs
@@ -9,18 +9,49 @@ public class DigitalBook : Book
private int _maxBorrowDays;
private float _latePenaltyPerDay;
- public DigitalBook(string bookName, string bookISBN)
- : base(bookName, bookISBN) { }
+ public DigitalBook(string bookName, string bookISBN): base(bookName, bookISBN)
+ {
+ _maxBorrowDays = 15;
+ _latePenaltyPerDay = 5;
+ }
- public void DetermineLoanLicense() { }
+ public void DetermineLoanLicense()
+ {
+ _maxBorrowDays = 15;
+ _latePenaltyPerDay = 5;
+ }
public override LibraryAsset BorrowBook()
{
+ foreach (var asset in Assets)
+ {
+ if (asset.Status == AssetStatus.Available)
+ {
+ asset.Status = AssetStatus.Loaned;
+ asset.Loan = new LoanPeriod(DateTime.Now,DateTime.MinValue, _maxBorrowDays);
+ return asset;
+ }
+ }
return null;
}
public override (TimeSpan, int, decimal) ReturnBook(int libID)
{
- return (TimeSpan.Zero, 0, 0);
+ var asset = findLibraryAsset(libID);
+ if (asset == null || asset.Status != AssetStatus.Loaned)
+ {
+ return (TimeSpan.Zero, 0, 0);
+ }
+ DateTime returnTime = DateTime.Now;
+
+ var loan = new LoanPeriod(asset.Loan.BorrowedOn, returnTime, _maxBorrowDays);
+ asset.Loan = loan;
+
+ asset.Status = AssetStatus.Available;
+ TimeSpan duration = loan.LoanDuration;
+ int lateDays = loan.LatePeriod.Days;
+ decimal penalty = lateDays * (decimal)_latePenaltyPerDay;
+
+ return (duration, lateDays, penalty);
}
}
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/paperbook.cs b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/paperbook.cs
index 18b8ddb..fe3dfc1 100644
--- a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/paperbook.cs
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/paperbook.cs
@@ -6,20 +6,46 @@ namespace LibraryAppInteractive.businesslogic;
public class PaperBook : Book
{
- private const int _MAX_BORROW_DAYS = 30;
- private const float _LATE_PENALTY_PER_DAY = 0.25f;
+ private const int _maxBorrowDays = 30;
+ private const float _latePenaltyPerDay = 0.25f;
- public PaperBook(string bookName, string bookISBN)
- : base(bookName, bookISBN) { }
+ public PaperBook(string bookName, string bookISBN): base(bookName, bookISBN)
+ {
+
+ }
public override LibraryAsset BorrowBook()
{
+ foreach (var asset in Assets)
+ {
+ if (asset.Status == AssetStatus.Available)
+ {
+ asset.Status = AssetStatus.Loaned;
+ asset.Loan = new LoanPeriod(DateTime.Now, DateTime.MinValue, _maxBorrowDays);
+ return asset;
+ }
+ }
return null;
}
public override (TimeSpan, int, decimal) ReturnBook(int libID)
{
- return (TimeSpan.Zero, 0, 0);
+ var asset = findLibraryAsset(libID);
+ if (asset == null || asset.Status != AssetStatus.Loaned)
+ {
+ return (TimeSpan.Zero, 0, 0);
+ }
+ DateTime returnTime = DateTime.Now;
+
+ var loan = new LoanPeriod(asset.Loan.BorrowedOn, returnTime, _maxBorrowDays);
+ asset.Loan = loan;
+
+ asset.Status = AssetStatus.Available;
+ TimeSpan duration = loan.LoanDuration;
+ int lateDays = loan.LatePeriod.Days;
+ decimal penalty = lateDays * (decimal)_latePenaltyPerDay;
+
+ return (duration, lateDays, penalty);
}
}
From ac7511385941ecf52eb56611f93de0bea1e2bfb3 Mon Sep 17 00:00:00 2001
From: kingbugbux <149598271+kingbugbux@users.noreply.github.com>
Date: Mon, 20 Apr 2026 02:02:19 -0400
Subject: [PATCH 6/6] fixed the searching through the books working and added
the whole admin page which lets you register a book and show all the books
and added comments through the code
---
.../LibraryApp/LibraryAdminPage.xaml | 6 +-
.../LibraryApp/LibraryAdminPage.xaml.cs | 62 ++++++++++++++++++-
.../LibraryApp/LibraryBrowsePage.xaml.cs | 12 ++--
.../LibraryApp/businesslogic/Book.cs | 27 +++++---
.../LibraryApp/businesslogic/Library.cs | 20 +++---
.../LibraryApp/businesslogic/assetstatus.cs | 1 +
.../LibraryApp/businesslogic/booktype.cs | 4 +-
.../LibraryApp/businesslogic/digitalbook.cs | 3 +
.../LibraryApp/businesslogic/libraryasset.cs | 8 +--
.../LibraryApp/businesslogic/loanperiod.cs | 1 +
.../LibraryApp/businesslogic/paperbook.cs | 2 +
11 files changed, 115 insertions(+), 31 deletions(-)
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryAdminPage.xaml b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryAdminPage.xaml
index 4f69272..e03c186 100644
--- a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryAdminPage.xaml
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryAdminPage.xaml
@@ -6,8 +6,12 @@
Title="Manage Book Assets">
+
+
+
+
-
+
\ No newline at end of file
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryAdminPage.xaml.cs b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryAdminPage.xaml.cs
index 2799d5e..948cb8b 100644
--- a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryAdminPage.xaml.cs
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryAdminPage.xaml.cs
@@ -1,3 +1,4 @@
+using LibraryAppInteractive.businesslogic;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -8,18 +9,73 @@ namespace LibraryAppInteractive;
public partial class LibraryAdminPage : ContentPage
{
- public LibraryAdminPage()
+ private Library _library;
+ public LibraryAdminPage(Library library)
{
InitializeComponent();
+ _library = library;
}
- private void RegisterBook(object sender, EventArgs e)
+ private async void RegisterBook(object sender, EventArgs e)
{
+ //once the button is pressed it gets all the entries and then and then displays a alert telling you that it was registered if there was no problems
+ string name = _txtName.Text;
+ string isbn = _txtIsbn.Text;
+ string author = _txtAuthor.Text;
+ BookType type = BookType.Paper;
+ if (_txtType.Text == "Paper" || _txtType.Text == "paper")
+ {
+ type = BookType.Paper;
+ }
+ else if (_txtType.Text == "Digital" || _txtType.Text == "digital")
+ {
+ type = BookType.Digital;
+ }
+ else
+ {
+ await DisplayAlert("error","Needs to be either paper or digital","Ok");
+ }
+
+ if (string.IsNullOrWhiteSpace(name) ||
+ string.IsNullOrWhiteSpace(isbn))
+ {
+ await DisplayAlert("Error", "Name and ISBN required", "OK");
+ return;
+ }
+ //had to google how to split mutiple authors into a array
+ string[] authors = author?
+ .Split(',', StringSplitOptions.RemoveEmptyEntries)
+ .Select(a => a.Trim())
+ .ToArray() ?? new string[0];
+
+ int copies = 1;
+
+ _library.RegisterBook(
+ name,isbn,authors,type,copies
+
+ );
+ await DisplayAlert("Success", "Book registered", "OK");
}
- private void DisplayBook(object sender, EventArgs e)
+ private async void DisplayBooks(object sender, EventArgs e)
{
+ //shows the list of all the books in a displayalert
+ var books = _library.GetAllBooks();
+
+ if (books == null || books.Count == 0)
+ {
+ await DisplayAlert("Library", "No books available", "OK");
+ return;
+ }
+
+ string result = "";
+
+ foreach (var book in books)
+ {
+ result += $"{book.Name} ({book.ISBN})\n";
+ }
+ await DisplayAlert("Books", result, "OK");
}
}
\ No newline at end of file
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryBrowsePage.xaml.cs b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryBrowsePage.xaml.cs
index 7cdae77..536177d 100644
--- a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryBrowsePage.xaml.cs
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/LibraryBrowsePage.xaml.cs
@@ -15,6 +15,7 @@ public LibraryBrowsePage(Library library)
private async void SearchBook(object sender, EventArgs e)
{
+ //lets you search for a book if it available and matches the name you type in case sensitive
if (_library == null)
{
await DisplayAlert("Error", "Library not initialized", "OK");
@@ -26,22 +27,25 @@ private async void SearchBook(object sender, EventArgs e)
if (book == null)
{
await DisplayAlert("Not found","No book availble","Ok");
+ return;
}
await DisplayAlert("Book found",$"Found the book {bookName}","Ok");
}
private async void BorrowBook(object sender, EventArgs e)
{
+ //lets you borrow a book based on the isbm given and then displays a alert saying you got the book
if (_library == null)
{
await DisplayAlert("Error", "Library not initialized", "OK");
return;
}
- string isbn = _txtISBN.Text;
+ string isbn = _txtISBN.Text?.Trim();
Book book = _library.FindBookByISBN(isbn);
if (book == null)
{
await DisplayAlert("Not found","No book found","Ok");
+ return;
}
@@ -49,7 +53,7 @@ private async void BorrowBook(object sender, EventArgs e)
if (asset == null)
{
await DisplayAlert("Not found", "No copies found", "Ok");
-
+ return;
}
await DisplayAlert("Book found", $"Borrowed the book {book.Name}", "Ok");
@@ -57,6 +61,7 @@ private async void BorrowBook(object sender, EventArgs e)
private async void OnReturnBook(object sender, EventArgs e)
{
+ //lets you return the book based off of the libid and isbn number and then adds it to the copy and then displays a alert saying its returned
if (_library == null)
{
await DisplayAlert("Error", "Library not initialized", "OK");
@@ -70,11 +75,10 @@ private async void OnReturnBook(object sender, EventArgs e)
}
int LibId = int.Parse(_txtLibID.Text);
Book book = _library.FindBookByISBN(isbn);
-
if (book == null)
{
await DisplayAlert("Not found", "No book found", "Ok");
-
+ return;
}
var result = book.ReturnBook(LibId);
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Book.cs b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Book.cs
index 2a4daee..377ca67 100644
--- a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Book.cs
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Book.cs
@@ -6,6 +6,7 @@ namespace LibraryAppInteractive.businesslogic;
public class Book
{
+ //sets all the variables
protected string _bookName;
protected string _bookISBN;
protected List _bookAuthorList;
@@ -14,6 +15,7 @@ public class Book
public string Name { get; set; }
public string ISBN { get; set; }
public List Authors { get; set; }
+ //gets the list of assets
public IEnumerable Assets
{
get
@@ -24,6 +26,7 @@ public IEnumerable Assets
public Book(string bookName, string bookISBN)
{
+ //gives the variables a value
Name = bookName;
ISBN = bookISBN;
_libAssetList = new List();
@@ -32,6 +35,7 @@ public Book(string bookName, string bookISBN)
public virtual bool CheckAvailability()
{
+ //checks the books availbility and wether its true or not
if (_libAssetList.Count == 0 || _libAssetList == null)
{
return false;
@@ -48,6 +52,7 @@ public virtual bool CheckAvailability()
public virtual LibraryAsset BorrowBook()
{
+ //lets you borrow a book if the book has the available status
foreach (var asset in _libAssetList)
{
if (asset.Status == AssetStatus.Available)
@@ -64,6 +69,7 @@ public virtual LibraryAsset BorrowBook()
public virtual (TimeSpan, int, decimal) ReturnBook(int libID)
{
+ //lets you return the book and add it back to the copies
var asset = findLibraryAsset(libID);
if (asset == null)
{
@@ -76,24 +82,23 @@ public virtual (TimeSpan, int, decimal) ReturnBook(int libID)
}
DateTime returnTime = DateTime.Now;
- asset.Loan = new LoanPeriod(asset.Loan.BorrowedOn, returnTime, 30);
- asset.Status = AssetStatus.Available;
- TimeSpan durationLoaned = asset.Loan.LoanDuration;
+ TimeSpan durationLoaned = returnTime - asset.Loan.BorrowedOn;
- int daysLate = asset.Loan.LatePeriod.Days;
+ int daysLate = (returnTime - asset.Loan.BorrowedOn).Days - 30;
//googled how to make a decimal literal with m
+ if (daysLate < 0)
+ {
+ daysLate = 0;
+ }
decimal penaltyFee = daysLate * 0.5m;
-
+ asset.Status = AssetStatus.Available;
+ asset.Loan = new LoanPeriod(DateTime.MinValue, DateTime.MinValue, 30);
return (durationLoaned, daysLate,penaltyFee);
}
- public virtual LibraryAsset ReserveBook()
- {
- return null;
- }
-
public LibraryAsset findLibraryAsset(int libID)
{
+ //gives you the library id
foreach (var asset in _libAssetList)
{
if (asset._libID == libID)
@@ -106,6 +111,7 @@ public LibraryAsset findLibraryAsset(int libID)
public LibraryAsset findNextAvailableAsset()
{
+ //finds the next availble asset that is availble
if (_libAssetList == null)
{
return null;
@@ -121,6 +127,7 @@ public LibraryAsset findNextAvailableAsset()
public void AddAsset(LibraryAsset asset)
{
+ //adds the asset to the list of books
if (_libAssetList == null)
{
_libAssetList = new List();
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Library.cs b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Library.cs
index dc6a477..a182eb1 100644
--- a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Library.cs
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/Library.cs
@@ -16,17 +16,14 @@ public class Library
public Library()
{
+ //creates a list of the books and the id
_bookList = new List();
- _libraryIdGeneratorSeed = default_libid_start;
- }
-
- private int GenerateLibId()
- {
- return _libraryIdGeneratorSeed++;
+ _libraryIdGeneratorSeed = 0;
}
public void CreateDefaultBooks()
{
+ //a default set of books
RegisterBook(
"Book1",
"1234",
@@ -52,11 +49,13 @@ public void CreateDefaultBooks()
public int DetermineLibId()
{
+ //adds one to the id
return _libraryIdGeneratorSeed++;
}
public Book RegisterBook(string bookName, string bookISBN, string[] authors, BookType bookType, int nCopies)
{
+ //registers a book to the list and all the info given as a book object
Book newbook;
switch (bookType)
{
@@ -87,6 +86,7 @@ public Book RegisterBook(string bookName, string bookISBN, string[] authors, Boo
public Book FindBookByName(string bookName)
{
+ //lets you find the book by its name by iterating through the list of books until it matches
if (_bookList == null)
{
return null;
@@ -103,17 +103,23 @@ public Book FindBookByName(string bookName)
public Book FindBookByISBN(string bookISBN)
{
+ //lets you find the book through the isbn number by iterating through the list
if (_bookList == null)
{
return null;
}
foreach (Book book in _bookList)
{
- if (book.ISBN != null && book.ISBN == bookISBN)
+ if (book.ISBN != null && book.ISBN.Equals(bookISBN))
{
return book;
}
}
return null;
}
+ public List GetAllBooks()
+ {
+ //returns the list of books
+ return _bookList;
+ }
}
\ No newline at end of file
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/assetstatus.cs b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/assetstatus.cs
index f8defe2..efb1c97 100644
--- a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/assetstatus.cs
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/assetstatus.cs
@@ -3,6 +3,7 @@
using System.Text;
namespace LibraryAppInteractive.businesslogic;
+//sets the enum values of the status of the book
public enum AssetStatus
{
Notavailable,
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/booktype.cs b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/booktype.cs
index 7b4fa71..b79a8f2 100644
--- a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/booktype.cs
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/booktype.cs
@@ -3,10 +3,10 @@
using System.Text;
namespace LibraryAppInteractive.businesslogic;
+//adds the values to the different types
public enum BookType
{
Paper = 1,
- Digital,
- Audio
+ Digital
}
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/digitalbook.cs b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/digitalbook.cs
index c3f66ee..faaac33 100644
--- a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/digitalbook.cs
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/digitalbook.cs
@@ -17,12 +17,14 @@ public DigitalBook(string bookName, string bookISBN): base(bookName, bookISBN)
public void DetermineLoanLicense()
{
+ //adds the values for the max days and penalty
_maxBorrowDays = 15;
_latePenaltyPerDay = 5;
}
public override LibraryAsset BorrowBook()
{
+ //lets you borrow the book if its available
foreach (var asset in Assets)
{
if (asset.Status == AssetStatus.Available)
@@ -37,6 +39,7 @@ public override LibraryAsset BorrowBook()
public override (TimeSpan, int, decimal) ReturnBook(int libID)
{
+ //lets you return the book and returns the copy to the list and changes the status to available
var asset = findLibraryAsset(libID);
if (asset == null || asset.Status != AssetStatus.Loaned)
{
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/libraryasset.cs b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/libraryasset.cs
index c112ff6..02b02c4 100644
--- a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/libraryasset.cs
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/libraryasset.cs
@@ -6,10 +6,9 @@ namespace LibraryAppInteractive.businesslogic;
public class LibraryAsset
{
- private Book _book;
+ public Book _book;
public int _libID;
- private AssetStatus _status;
- private LoanPeriod _loanPeriod;
+ public LoanPeriod _loanPeriod;
public AssetStatus Status { get; set; }
public LoanPeriod Loan { get; set; }
@@ -17,9 +16,10 @@ public class LibraryAsset
public LibraryAsset(int libID, Book book)
{
+ //sets up the values for a asset of books
_libID = libID;
_book = book;
- _status = AssetStatus.Available;
+ Status = AssetStatus.Available;
}
}
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/loanperiod.cs b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/loanperiod.cs
index 5d3bf45..9f9b7e9 100644
--- a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/loanperiod.cs
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/loanperiod.cs
@@ -48,6 +48,7 @@ public TimeSpan LatePeriod {
public LoanPeriod(DateTime borrowedOn, DateTime returnedOn, int days)
{
+ //sets all the values for a loan period
_borrowedOn = borrowedOn;
_returnedOn = returnedOn;
_dueDate = borrowedOn.AddDays(days);
diff --git a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/paperbook.cs b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/paperbook.cs
index fe3dfc1..ae9fbc2 100644
--- a/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/paperbook.cs
+++ b/LibraryApp_Interactive/LibraryAppInteractive/LibraryApp/businesslogic/paperbook.cs
@@ -16,6 +16,7 @@ public PaperBook(string bookName, string bookISBN): base(bookName, bookISBN)
public override LibraryAsset BorrowBook()
{
+ //lets you borrow a book if it it availble and then takes one out of the copies
foreach (var asset in Assets)
{
if (asset.Status == AssetStatus.Available)
@@ -30,6 +31,7 @@ public override LibraryAsset BorrowBook()
public override (TimeSpan, int, decimal) ReturnBook(int libID)
{
+ //lets you return a book and then the status goes avaible and adds it to the copy
var asset = findLibraryAsset(libID);
if (asset == null || asset.Status != AssetStatus.Loaned)
{