Snego
Snego
CC#
Created by Snego on 1/17/2024 in #help
Could someone help me with this task
Thank you for trying to help tho)
24 replies
CC#
Created by Snego on 1/17/2024 in #help
Could someone help me with this task
After some more hours of work I have fixed everything)
24 replies
CC#
Created by Snego on 1/17/2024 in #help
Could someone help me with this task
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Library
{
public class Loan
{
public Book BorrowedBook { get; set; }
public string BorrowerName { get; set; }
public DateTime BorrowDate { get; set; }
public DateTime? ReturnDate { get; set; }

public Loan(Book borrowedBook, string borrowerName)
{
BorrowedBook = borrowedBook;
BorrowerName = borrowerName;
BorrowDate = DateTime.Now;
}

public bool IsBorrowed()
{
return ReturnDate == null;
}

public void ReturnBook()
{
if (IsBorrowed())
{
ReturnDate = DateTime.Now;
BorrowedBook.IsBorrowed = false;
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Library
{
public class Loan
{
public Book BorrowedBook { get; set; }
public string BorrowerName { get; set; }
public DateTime BorrowDate { get; set; }
public DateTime? ReturnDate { get; set; }

public Loan(Book borrowedBook, string borrowerName)
{
BorrowedBook = borrowedBook;
BorrowerName = borrowerName;
BorrowDate = DateTime.Now;
}

public bool IsBorrowed()
{
return ReturnDate == null;
}

public void ReturnBook()
{
if (IsBorrowed())
{
ReturnDate = DateTime.Now;
BorrowedBook.IsBorrowed = false;
}
}
}
}
24 replies
CC#
Created by Snego on 1/17/2024 in #help
Could someone help me with this task
using System;
using System.Collections.Generic;

namespace Library
{

public class Book
{
public string Title { get; set; }
public string Author { get; set; }
public string Description { get; set; }
public bool IsBorrowed { get; set; }

public Genre genre;


public Book(string title, string author, string desc, Genre genre)
{
Title = title;
Author = author;
Description = desc;
this.genre = genre;
IsBorrowed = false;
}

}
}
using System;
using System.Collections.Generic;

namespace Library
{

public class Book
{
public string Title { get; set; }
public string Author { get; set; }
public string Description { get; set; }
public bool IsBorrowed { get; set; }

public Genre genre;


public Book(string title, string author, string desc, Genre genre)
{
Title = title;
Author = author;
Description = desc;
this.genre = genre;
IsBorrowed = false;
}

}
}
24 replies
CC#
Created by Snego on 1/17/2024 in #help
Could someone help me with this task
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Library
{
public partial class Form3 : Form
{
public string BorrowerName { get; set; }
public Form3()
{
InitializeComponent();
}

private void btnReturn1_Click_1(object sender, EventArgs e)
{
BorrowerName = textBoxBorrowerName.Text;

if (!string.IsNullOrEmpty(BorrowerName))
{
DialogResult = DialogResult.OK;
}
else
{
MessageBox.Show("Please enter the borrower's name.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Library
{
public partial class Form3 : Form
{
public string BorrowerName { get; set; }
public Form3()
{
InitializeComponent();
}

private void btnReturn1_Click_1(object sender, EventArgs e)
{
BorrowerName = textBoxBorrowerName.Text;

if (!string.IsNullOrEmpty(BorrowerName))
{
DialogResult = DialogResult.OK;
}
else
{
MessageBox.Show("Please enter the borrower's name.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
24 replies
CC#
Created by Snego on 1/17/2024 in #help
Could someone help me with this task
using System.Collections.Generic;

namespace Library
{

public class Library
{

public enum Genre
{
All,
Fantasy,
Detective,
Fiction,
Thriller,
Biography
}



public static List<Book> books = new List<Book>();

public static List<Book> GetBooks()
{
return books;
}

public static void AddBook(Book book)
{
books.Add(book);
}

public static void RemoveBook(Book book)
{
books.Remove(book);
}

}

}
using System.Collections.Generic;

namespace Library
{

public class Library
{

public enum Genre
{
All,
Fantasy,
Detective,
Fiction,
Thriller,
Biography
}



public static List<Book> books = new List<Book>();

public static List<Book> GetBooks()
{
return books;
}

public static void AddBook(Book book)
{
books.Add(book);
}

public static void RemoveBook(Book book)
{
books.Remove(book);
}

}

}
24 replies
CC#
Created by Snego on 1/17/2024 in #help
Could someone help me with this task
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Library
{
public partial class Form2 : Form
{
public string BorrowerName { get; set; }
public Form2()
{
InitializeComponent();
}

private void btnBorrow_Click(object sender, EventArgs e)
{
string borrowerName = textBoxName.Text;

if (!string.IsNullOrEmpty(borrowerName))
{
MessageBox.Show($"The book has been borrowed by {borrowerName} at {DateTime.Now}.", "Borrowed");
this.DialogResult = DialogResult.OK;
}
this.Close();
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Library
{
public partial class Form2 : Form
{
public string BorrowerName { get; set; }
public Form2()
{
InitializeComponent();
}

private void btnBorrow_Click(object sender, EventArgs e)
{
string borrowerName = textBoxName.Text;

if (!string.IsNullOrEmpty(borrowerName))
{
MessageBox.Show($"The book has been borrowed by {borrowerName} at {DateTime.Now}.", "Borrowed");
this.DialogResult = DialogResult.OK;
}
this.Close();
}
}
}
24 replies
CC#
Created by Snego on 1/17/2024 in #help
Could someone help me with this task
using LINQtoCSV;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Library
{
[Serializable]

public enum Genre
{
All,
Fantasy,
Detective,
Fiction,
Thriller,
Biography
}
public class BookClass
{
[CsvColumn(FieldIndex =1)]
public string Title { get; set; }
[CsvColumn(FieldIndex =2)]
public string Author { get; set; }
[CsvColumn(FieldIndex = 3)]
public string Description { get; set; }

[CsvColumn(FieldIndex = 4)]
public Genre Genre { get; set; }
}
}
using LINQtoCSV;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Library
{
[Serializable]

public enum Genre
{
All,
Fantasy,
Detective,
Fiction,
Thriller,
Biography
}
public class BookClass
{
[CsvColumn(FieldIndex =1)]
public string Title { get; set; }
[CsvColumn(FieldIndex =2)]
public string Author { get; set; }
[CsvColumn(FieldIndex = 3)]
public string Description { get; set; }

[CsvColumn(FieldIndex = 4)]
public Genre Genre { get; set; }
}
}
24 replies
CC#
Created by Snego on 1/17/2024 in #help
Could someone help me with this task
cs
cs
24 replies
CC#
Created by Snego on 1/17/2024 in #help
Could someone help me with this task
So basically it should record the borrowerName and the BorrowTime, then check in the loans if there is a borrowedBook with the name that matches the selected item's name in the listBox
24 replies
CC#
Created by Snego on 1/17/2024 in #help
Could someone help me with this task
Basically it does not store whether the book is borrowed or not, and due to that, it always returns the error messagebox saying: "Book not found or already returned for the specified borrower."
24 replies