Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Code is in Java, Create a java file and a xml file, this is an android studio assignment . I need help implementing this test

Code is in Java, Create a java file and a xml file, this is an android studio assignment . I need help implementing this test case

{Display Main Menu}

  1. The use case begins when the System prompts the Customer with options of CreateAccount, Place Hold, and Manage System.
  2. The Customer selects the Place Hold option.

{Enter Genre}

  1. The System prompts the Customer to select a genre from the following: Computer Science, Fiction, Memoir.

{Select Book}

  1. Based on the genre selected by the Customer, the System displays all books available for the reservation. In our case, we assume that there are three books in the library as below when the System starts:
Book Title Author Genre
A Heartbreaking Work of Staggering Genius Dave Eggers Memoir
The IDA Pro Book Chris Eagle Computer Science
Frankenstein Mary Shelley Fiction

  1. The Customer picks a book that they would like to check out.

{Login to System}

  1. The System prompts the Customer to enter their username and password.
  2. The Customer enters their username and password.
  3. The System confirms that the Customer information is valid.

{Confirmation}

  1. The System displays the Customer username, book title, and reservation number.

(10) The System prompts the Customer if the information is correct.

(11) The Customer indicates that the information is correct.

{Log the Transaction}

(12) The System records the transaction information that includes a transaction type (= Place Hold), the customer username, and a reservation number.

{Use Case Ends}

(13) The System displays the main menu.

(14) The use case ends.

Here is my LibraryDao

@Dao public interface LibraryDao { @Insert void CreateBook(Library library); @Query("SELECT * FROM LibraryDB") List getAllBooks(); @Query("SELECT * FROM LibraryDB WHERE BookTitle= :bookTitle AND Author= :author AND Genre= :genre") Library checkout(String bookTitle, String author, String genre); @Query("SELECT * FROM LibraryDB WHERE Genre LIKE 'Memoir'") List getAllMemoir(); @Query("SELECT * FROM LibraryDB WHERE Genre LIKE 'Computer Science'") List getAllComputerScience(); @Query("SELECT * FROM LibraryDB WHERE Genre LIKE 'Fiction'") List getAllFiction(); @Query("SELECT COUNT(*) FROM LibraryDB") int count(); @Delete void delete(Library library); } Here is my Library file

@Entity(tableName = "LibraryDB") public class Library { @PrimaryKey(autoGenerate = true) private int id; @ColumnInfo(name ="BookTitle") private String BookTitle; @ColumnInfo(name = "Author") private String Author; @ColumnInfo (name = "Genre") private String Genre; public Library( String BookTitle, String Author, String Genre) { this.BookTitle = BookTitle; this.Author = Author; this.Genre = Genre; } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getBookTitle() { return BookTitle; } public void setBookTitle(String bookTitle) { BookTitle = bookTitle; } public String getAuthor() { return Author; } public void setAuthor(String author) { Author = author; } public String getGenre() { return Genre; } public void setGenre(String genre) { Genre = genre; } @Override public String toString() { return "Library{" + "id=" + id + ", BookTitle='" + BookTitle + '\'' + ", Author='" + Author + '\'' + ", Genre='" + Genre + '\'' + '}'; } } Here is my Database

@Database(entities = {Accounts.class,Library.class},version = 5,exportSchema = false) public abstract class ProjectDatabase extends RoomDatabase { public abstract AccountsDao accounts(); public abstract LibraryDao library(); private static ProjectDatabase sInstance; public static synchronized ProjectDatabase getInstance(Context context){ if(sInstance == null){ sInstance= Room.databaseBuilder(context.getApplicationContext(), ProjectDatabase.class,"Project.db") .fallbackToDestructiveMigration() .allowMainThreadQueries() .build(); } return sInstance; } public void populateAccountData(){ if(accounts().count()==0){ runInTransaction(()->{ //Added default users Accounts act1= new Accounts("hShuard","m@thl3t3"); accounts().CreateUser(act1); accounts().CreateUser(new Accounts("bMishra","bioN@no")); accounts().CreateUser(new Accounts("shirleyBee","Carmel2Chicago")); accounts().CreateUser(new Accounts("!admin2","!admin2")); }); } if(library().count()==0){ runInTransaction(()->{ Library books= new Library("A Heartbreaking Work of Staggering Genius","Dave Eggers","Memoir"); library().CreateBook(books); library().CreateBook(new Library("The IDA Pro Book","Chris Eggers","Computer Science")); library().CreateBook(new Library("Frankenstein","Mary Shelley","Fiction")); }); } } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Explain relationships among objects and the concept of inheritance

Answered: 1 week ago

Question

Consistently develop management talent.

Answered: 1 week ago

Question

Create a refreshed and common vision and values across Europe.

Answered: 1 week ago

Question

Provide the best employee relations environment.

Answered: 1 week ago