Question
error correct

Page 11 of 1 // -- // Find 4 or 5 errors on this page. // Source code file Test.java import java.util.ArrayList; import java.
Page 12 of 12 // Find 4 or 5 errors on this page. // Source code file: Test 2.java // These four import statements for // JUn
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Page 1 :

1) private static void main(String args[]) : Main method cannot be private. It should always be declared public.Correct line should be public static void main(String args[])

2)ArrayList<LibraryItem> col = new ArrayList[LibraryItem](): In the second part of this statement, the subscript notation is used [] instead of the generic notation <>. The subscript is used to denote the arrays, here we are using a Collection where we use generic notation. So <> should be used instead of [] in the second part.

3) col.append(item1) and col.append(item2): ArrayList does not have an append method. It should be add instead of append.

4)System.out.println(col[0].isCheckedOut()): This is the last line on the page. Here we are again using the [] subscript notation which should be used with array instead. So this will not work. Correct way should be col.get(0).isCheckedOut();

Page 2 :

1) item1 = LibraryItem("A1234"): Here new keyword is missing which is used when we are creating a new object. Should be new LibraryIem("A1234);

2) assertEquals(item1.toString(), A1234 true): The A1234 should be inside double quotes like this "A1234 true".

3)assertEquals(item2.getAuthor(), "Oliver Twist");); : Here there are 2 paranthesis and semi colons. This is wrong.

Should be just "Oliver Twist");

4)assertEquals(item1.isCheckedOut(), false) : The second line in the testLibraryItem, here it should be true instead of false, as in the next line we are checking out the item, so the value before that must be true, hence here it should be true as well to pass the test case.

Add a comment
Know the answer?
Add Answer to:
error correct Page 11 of 1 // -- // Find 4 or 5 errors on this...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Modify the library program as follows: Create a method in the LibraryMaterial class that accepts a...

    Modify the library program as follows: Create a method in the LibraryMaterial class that accepts a string s as a parameter and returns true if the title of the string is equal to s. Create the same method for your library material copies. Note that it will need to be abstract in the LibraryMaterialCopy class MY CODE **************************************************************** LibraryCard: import java.util.List; import java.util.ArrayList; import java.time.LocalDate; import    java.time.temporal.ChronoUnit; public class LibraryCard {    private String id;    private String cardholderName;   ...

  • This is my code for a TicTacToe game. However, I don't know how to write JUnit...

    This is my code for a TicTacToe game. However, I don't know how to write JUnit tests. Please help me with my JUnit Tests. I will post below what I have so far. package cs145TicTacToe; import java.util.Scanner; /** * A multiplayer Tic Tac Toe game */ public class TicTacToe {    private char currentPlayer;    private char[][] board;    private char winner;       /**    * Default constructor    * Initializes the board to be 3 by 3 and...

  • (JAVA NetBeans) Write programs in java Example 9.13~9.15 //Book.Java public class Book { private String title; private...

    (JAVA NetBeans) Write programs in java Example 9.13~9.15 //Book.Java public class Book { private String title; private String author; private double price; /** * default constructor */ public Book() { title = ""; author = ""; price = 0.0; } /** * overloaded constructor * * @param newTitle the value to assign to title * @param newAuthor the value to assign to author * @param newPrice the value to assign to price */ public Book(String newTitle, String newAuthor, double newPrice)...

  • Below, you can find the description of your labwork for today. You can also find the...

    Below, you can find the description of your labwork for today. You can also find the expected output of this code in the Application Walkthrough section. You are going to improve your existing Money & Stock Trading Platform on previous week’s labwork by incorporating Collections. In previous labworks, you have used arrays for holding Customer and Item objects. For this labwork you need to use ArrayList for holding these objects. So, rather than defining Customer[] array, you need to define...

  • Exception handling is a powerful tool used to help programmers understand exception errors. This tool separates...

    Exception handling is a powerful tool used to help programmers understand exception errors. This tool separates the error handling routine from the rest of the code. In this application, you practice handling exception errors. You use sample code that was purposefully designed to generate an exception error, and then you modify the code so that it handles the errors more gracefully. For this Assignment, submit the following program: The following code causes an exception error: import java.io.BufferedReader; import java.io.IOException; import...

  • this needs to be in Java: use a comparator class which is passed into the sort...

    this needs to be in Java: use a comparator class which is passed into the sort method that is available on the ArrayList. import java.util.Scanner; public class Assign1{ public static void main(String[] args){ Scanner reader = new Scanner (System.in); MyDate todayDate = new MyDate(); int choice = 0; Library library = new Library(); while (choice != 6){ displayMainMenu(); if (reader.hasNextInt()){ choice = reader.nextInt(); switch(choice){ case 1: library.inputResource(reader, todayDate); break; case 2: System.out.println(library.resourcesOverDue(todayDate)); break; case 3: System.out.println(library.toString()); break; case 4: library.deleteResource(reader,...

  • Need three seperate files. ShoppingCartManager.java ShoppingCart.java ItemsToPurchase.java These are from part 1 what do you mean...

    Need three seperate files. ShoppingCartManager.java ShoppingCart.java ItemsToPurchase.java These are from part 1 what do you mean by deep study 7.25 LAB*: Program: Online shopping cart (Part 2) Note: Creating multiple Scanner objects for the same input stream yields unexpected behavior. Thus, good practice is to use a single Scanner object for reading input from System.in. That Scanner object can be passed as an argument to any methods that read input This program extends the earlier Online shopping cart program (Consider...

  • For this assignment, you will write a program to work with Huffman encoding. Huffman code is...

    For this assignment, you will write a program to work with Huffman encoding. Huffman code is an optimal prefix code, which means no code is the prefix of another code. Most of the code is included. You will need to extend the code to complete three additional methods. In particular, code to actually build the Huffman tree is provided. It uses a data file containing the frequency of occurrence of characters. You will write the following three methods in the...

  • Need help with a number guessing game in java 1) You should store prior guessses in...

    Need help with a number guessing game in java 1) You should store prior guessses in a linked list, and the nodes in the list must follow the order of prior guesses. For example, if the prior guesses are 1000, 2111, 3222 in that order, the nodes must follow the same order 2) You should store the candidate numbers also in a linked list, and the nodes must follow the order of numbers (i.e. from the smallest to the largest)....

  • I am currently using eclipse to write in java. A snapshot of the output would be...

    I am currently using eclipse to write in java. A snapshot of the output would be greatly appreciated to verify that the program is indeed working. Thanks in advance for both your time and effort. Here is the previous exercise code: /////////////////////////////////////////////////////Main /******************************************* * Week 5 lab - exercise 1 and exercise 2: * * ArrayList class with search algorithms * ********************************************/ import java.util.*; /** * Class to test sequential search, sorted search, and binary search algorithms * implemented in...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT