Please help me out with my project. If you could help
with me with some methods code and the application class i will be
thankful.
libraryHoldings.txt
Project Part 1 -
Book Class - Book.java
package library;
public class Book{
private String title;
private String author;
private String status;
//Parametrized constructor
public Book(String title1, String author1, String
status1){
title = title1;
author = author1;
setStatus(status1);
}
//Mutator method
public void setTitle(String t){
title = t;
}
public void setAuthor(String a){
author = a;
}
public void setStatus(String s){
if(s.equals("available") || s.equals("out") ||
s.equals("overdue")){
status = s;
}
}
//Accessor Method
public String getTitle(){
return title;
}
public String getAuthor(){
return author;
}
public String getStatus(){
return status;
}
//toString Method
public String toString(){
return title + " by " + author + " is currently " +
status + ".";
}
}
BookApp Class - BookApp.java
package library;
public class BookApp {
public static void main(String[]
args) {
Book b = new Book("Of Mice and
Men", "John Steinbeck", "available");
System.out.println("Test the
parameterized Book constructor and call the toString
method:");
System.out.println(b);
System.out.println();
System.out.println("Test
the accessors:");
System.out.println("Title: " +
b.getTitle());
System.out.println("Author: " +
b.getAuthor());
System.out.println("Status: " +
b.getStatus());
System.out.println();
System.out.println("Test the
mutators on the same object and call the toString method:");
b.setTitle("Romeo and
Juliet");
b.setAuthor("William
Shakespeare");
b.setStatus("out");
System.out.println(b);
System.out.println();
System.out.println("Set the status
to damaged and call the toString method:");
b.setStatus("damaged");
System.out.println(b);
System.out.println();
}
}
Library Programming Project Part II - no lates on any part Objectives: • To practice writing and testing programmer-defined classes. • To practice defining and using an array of objects. • To gain experience in developing program logic. • To practice writing documentation that explains what individual parts of the programmer- defined class and the application class do. The Problem: A small library has decided to create a new automated system for checking books in and out of the library. You have been hired to write the program for this system. The library employees will be allowed to check out a book, return a book, mark a book as overdue and request a list of books based upon the book's status (available, out or overdue). Specifications: To complete this assignment you will need to incorporate the Book class you designed in Part 1, and implement two new classes: an application class (LibraryApp.java) and a Library class. The specifications for each are outlined below. All classes will be part of a project called library (recall that the project name should be all lower-case letters). For Part I of this project, you defined the Book class and the BookApp testing class. Recall that the package name should be specified when creating classes and that it should have the same name as the project. If you are, for any reason, uncertain about the validity of the Book class you have developed in Part I, please speak with me or email me prior to beginning development of the Library class. Once you are certain that the Book class is working correctly, you can begin working on the Library class. In the library project, create a new class called Library. An object of type Library will contain books and will provide methods that allow the application class to add a book to the library, check out a book, return a book, mark a book as overdue and to request a list of books based upon the book's status. The Programmer Defined Class - Library There are multiple ways in which to design and implement the Library and the application classes. You should thoroughly read the descriptions for both prior to developing your code. The Library class should define an instance variable that can refer to an array that stores references to Book objects and one to store the total number of books that the library owns (regardless of the book's status). The Library class should provide the following behaviors: A books instance variable for the array of Book objects, a numBooks instance variable to keep track of the number of Book objects in the array. • A default constructor that creates a Book array with a capacity of 50 books and sets the number of books to 0. Page 1 of 7
Methods: addBook - This method inserts a book into the library. It must make sure there is space available before putting the book into the next available index. Place the book in the next available location immediately to the right of the other books. One parameter of type Book is required. No return value is needed. o search - Find a book in the library by its title. This method searches the array for a book using the title specified by the parameter, a string. If it's found, the index where it is found is returned. If it's not found, return -1. For efficiency, make sure to stop looking once the book is found. checkOut - Check out a book by its title, specified in the parameter, a string. Call the search method first to find the book and ensure it's in the array. Once it is found, the method must make sure the book the status is "available" before changing its status to "out." This method should return true if the book was successfully checked out, false otherwise. checkin - Return a book by its title, specified in the parameter, a string. Call the search method first to find the book and ensure it's in the array. Once it is found, the method must make sure the book is either "out" or "overdue" before changing its status to "available." This method should return true if the book was successfully returned, false otherwise. o markOverdue - Mark a book as overdue by title, specified in the parameter, a string. Call the search method first to find the book and ensure it's in the array. Once it is found, the method must make sure the book is "out" before changing its status “overdue." This method should return true if the book was successfully marked as overdue, false otherwise. o findBooksByStatus - Find books by status, available," "out, or "overdue," specified by the parameter, a string. The method should create a String containing all the book information (state of the Book object) for each book with the specified status. Return a reference to the created string. The text below demonstrates the format of the return string for the findBooksByStatus method when the parameter contains the string "available". The Hunger Games by Suzanne Collins is currently available. Catching Fire by Suzanne Collins is currently available. Go Set a Watchman by Harper Lee is currently available. Great Expectations by Charles Dickens is currently available. The Lion, the Witch and the Wardrobe by C. S. Lewis is currently available. Adventures of Huckleberry Finn by Mark Twain is currently available. The Grapes of Wrath by John Steinbeck is currently available. otoString - Return a reference to a String containing the state of the whole Library. This method will rely on the information returned by the toString method defined in the Book class. The text below demonstrates the format of the return string for the toString method: The Hunger Games by Suzanne Collins is currently available. Catching Fire by Suzanne Collins is currently available. Mockingjay by Suzanne Collins is currently out.
Insurgent by Veronica Roth is currently overdue. Allegiant by Veronica Roth is currently out. Go Set a Watchman by Harper Lee is currently available. To Kill a Mockingbird by Harper Lee is currently out. A Christmas Carol by Charles Dickens is currently out. A Tale of Two Cities by Charles Dickens is currently overdue. Great Expectations by Charles Dickens is currently available. The Old Man and The Sea by Ernest Hemingway is currently overdue. For Whom the Bell Tolls by Ernest Hemingway is currently out. The Chronicles of Narnia by C. S. Lewis is currently overdue. The Lion, the Witch and the Wardrobe by c. S. Lewis is currently available. The Great Gatsby by F. Scott Fitzgerald is currently out. Adventures of Huckleberry Finn by Mark Twain is currently available. The Adventures of Tom Sawyer by Mark Twain is currently overdue. Of Mice and Men by John Steinbeck is currently overdue. The Grapes of Wrath by John Steinbeck is currently available. The Pearl by John Steinbeck is currently overdue. Pride and Prejudice by Jane Austen is currently out. The Jungle Books by Rudyard Kipling is currently out. Slaughterhouse-Five by Kurt Vonnegut is currently overdue. Macbeth by William Shakespeare is currently out. Each constructor/method should be documented using JavaDoc comments. Make sure the JavaDoc explains the methods to a person not familiar with the code. The Application Class Before starting development, watch the walk-through video on YouTube (in the Library Project part 2 folder on Blackboard) to see how the finished product should behave. Name the class Library App. This class will not be graded automatically by codePost. Your code will be manually graded. The application class should: • Create a Library object by calling the default constructor. • Read in data about books to be added to the library from a file named library Holdings.txt (see reference document) that you will download from Blackboard. The file contains: o the number of books in the file o for each book it has • the title of the book • the author of the book the book's status • As you read in the information for each book from the file, create a Book object and add it to the Library. After all data has been read from the file, close the file. • Display a menu and get the user's choice, using the showOptionDialog method defined in the JOptionPane class (see reference document), which provides the user with the following options:
Main Menu х ? Enter your choice. Check Out Book Return Book Mark Book as Overdue Show Books Quit The showOptionDialog method displays a series of buttons and allows the user to select from the given set of options. For example, String[] choices = {"Option 1", "Option 2", "Option 3", "Option 4"}; int choice = JOptionPane.showOptionDialog null, "Enter your choice...", l/text displayed in the window "Main Menu", l/text displayed in the window's title bar JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, choices, l/text to be displayed in each button choices[0]); 1/default button would display the following dialog box and choice would get a value of 0, 1, 2, or 3 depending on the choice selected by the user. If a 0 is returned, the user clicked the "Option 1" button. If a 1 is returned, the user clicked the "Option 2" button, etc... Main Menu x ? Enter your choice... Option 1 Option 2 Option 3 Option 4 Process the user's choice (call the appropriate method in the Library class to handle the request). To check out, return or mark a book as overdue, the user must be prompted to enter the title of the book. The user should see a message indicating if the action was performed or not. If the user wants to see a listing of books that matches the specified criteria, the user must get a 2nd dialog box that displays the three options, available, out and overdue before calling the appropriate method in the Library class. *Note - the video walkthrough shows this part of the program with capitalized Available, Out, and Overdue. Since the Book class uses lowercase letters, use lowercase letters instead of how the video shows it. o If the user chooses to quit, the program should terminate.
• The menu should be displayed and the user's choice should be processed until s/he chooses to quit. • Include comments that describe what the application class does. You are required to use JOptionPane methods (see reference document) to display menus, prompt the user for input, and/or to display output. All Input/Output must be done using JOptionPane’s dialog boxes. JOptionPane's showMessageDialog method is used to display output in a dialog box. For example, JOptionPane.showMessageDialog( "The value of x is " + x, l text displayed within the window "Display Value", l/text displayed in the window's title bar JOptionPane. INFORMATION_MESSAGE); would display the following dialog box assuming that 10 stored in the variable x. null, x Display Value i The value of x is 10 OK
Citation Policy: This assignment should be worked on individually to help you practice the material covered in class. However, you may work with other students as long as you cite the name(s) of who you worked with and all students understand the assignment submitted. Failure to cite other people is considered plagiarism. You may receive help from your instructor or from the Computer Learning Center in B225. Grading: You will be graded on the correctness of the program submitted on codePost and the Library Project Part II Tracing assignment. Correctness will be based upon whether the program meets the requirements and works properly. Does the program submitted display all information? Are the values correct? • 20 points - Book.java and BookApp.java- this was graded in Part I. • 10 points - Library Project Part I Tracing assignment - graded in Part I. • 30 points - Library.java - automatically graded by code Post and manually graded for comments, style, Javadoc, proper use of iftelse statements, proper use of loops - no lates 30 points - Library App.java - upload to codePost. Your code will be manually reviewed for correctness and inspected for style, design, efficiency, readability, and comments. Make sure you see the Grading Criteria on the last page of this document to know how your code will be assessed. • 10 points - Library Project Part II Tracing assignment on MyOpenMath - lates not accepted Completion checklist (also see the Grading Criteria on the last page): • Did you watch the walk-through video on YouTube to compare the functionality of your project to the finished product in the video? • Does your program correctly check out a book? Does it properly return a book? Does the toString method return all information in a well-designed, readable format? • Have you used descriptive variable names? • Did you comment each logical grouping of statements with descriptive single line comments? • Did you appropriately use if statements and if/else statements in the correct type of scenario? Use simple if statements where appropriate, use nested if-else statements where appropriate. • Did you use loops where instructed to and where appropriate? Did you use the appropriate type of loop for a particular scenario? • Did you write the simplest and most efficient code possible? • Does your code have appropriate line spacing for readability? • Is the Javadoc complete and sufficient?
Student uses either nested if/else statements or a switch statement to handle the user choice from the main menu. Do not use simple if statements. (5 points deducted if using simple if statements) Student does NOT use simple if statements to handle the user choice from the show books menu. (5 points deducted if student uses simple if statements) • The student writes clean code. For example, code that is repeatedly identically several times in several iflelse blocks should be removed and placed outside of the blocks so it only appears once (improves readability). (4 points deducted if code is not clean) • There are descriptive comments throughout the main method. The student adequately explains what each logically grouped lines of code does. (10 points deducted if missing) Javadoc at the top of the class is complete, with title, description, and author. Description is at least a couple sentences. (5 points deducted if missing) Java naming convention and styling conventions are followed. (4 points deducted if missing) The menu should be displayed and the user's choice should be processed until s/he chooses to quit. Without this feature, the program ends after the user chooses one item on the menu. (15 points deducted if the student only processes user's choice once and ends the program)
Please help me out with my project. If you could help with me with some methods code and the application class i will be
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Please help me out with my project. If you could help with me with some methods code and the application class i will be
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!