Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Consider the class diagram without the use of an IDE: 1. Write the definition of class Book, which is a child class of Product.
Consider the class diagram without the use of an IDE: 1. Write the definition of class Book, which is a child class of Product. Only write the definition of class Book II. Write the definition of main() to perform the following steps: 1. Create an ArrayList object for storing Book objects. 2. Open a file named forSale.txt.The file contains two columns for name and pages separated by a single tab (sample entries in Figure 2). If a FileNotFoundException is raised, print an error message and terminate the program. Do not throw the exception. 3. Read all lines from the file as follows Using Regular Expressions validate the value of name and accept the value if it: 1. Starts with an uppercase letter 2. Followed by two or more letters (lower or upper) 3. Followed by exactly one number Note: The values in red in Figure 2 are examples of rejected values. If the value of name is valid, add an object to the ArrayList forSale.txt Book1 300 Book2 500 book Book44 911 Figure 2: Input file 4. Finally, print all the values in the ArrayList. You may assume that toString() in class Book object is implemented. Activate Go to Setti Book pages int +TextBook (String, int) + getPages() : int Product name: String + Product (String) + getName() : String + setName() : String Figure 1: UML Class Diagram
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started