need main class in java with user input that prints like the following in a (y/n) loop. reads from a txt file and second class

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

need main class in java with user input that prints like the following in a (y/n) loop. reads from a txt file and second class

**Search Results for "Zelda" Games**

- **Name:** The Legend of Zelda: Ocarina of Time  
  **Platforms:** Nintendo 64  
  **Year:** 1998  

- **Name:** The Legend of Zelda: Breath of the Wild  
  **Platforms:** Wii U, Switch  
  **Year:** 2017  

- **Name:** The Legend of Zelda: Twilight Princess  
  **Platforms:** GameCube, Wii  
  **Year:** 2006  

- **Name:** The Legend of Zelda: The Wind Waker  
  **Platforms:** GameCube  
  **Year:** 2003  

- **Name:** The Legend of Zelda: Majora's Mask  
  **Platforms:** Nintendo 64  
  **Year:** 2000  

**Prompt:** Do you want to search again? (y/n)
Transcribed Image Text:**Search Results for "Zelda" Games** - **Name:** The Legend of Zelda: Ocarina of Time **Platforms:** Nintendo 64 **Year:** 1998 - **Name:** The Legend of Zelda: Breath of the Wild **Platforms:** Wii U, Switch **Year:** 2017 - **Name:** The Legend of Zelda: Twilight Princess **Platforms:** GameCube, Wii **Year:** 2006 - **Name:** The Legend of Zelda: The Wind Waker **Platforms:** GameCube **Year:** 2003 - **Name:** The Legend of Zelda: Majora's Mask **Platforms:** Nintendo 64 **Year:** 2000 **Prompt:** Do you want to search again? (y/n)
```java
import java.util.*;
import java.io.*;

public class Game{
    String name;
    int year;
    String platforms;
    Game(String name, String p, int year){
        this.name = name;
        platforms = p;
        this.year = year;
    }

    private String[] parsePlatforms(String s){
        String[] platforms = s.split(", ");
        return platforms;
    }

    private String getPlatforms(){
    }

    public String toString() {
    }

    public boolean matchesYear(int y){
        if(this.year == y)
        return true;
        else return false;
    }

    public boolean matchesPlatform(String p){
        if(this.platforms.contains(p))
        return true;
        else return false;
    }

    public boolean matchesName(String str){
        if(this.name.contains(str))
        return true;
        else return false;
    }
}
```

### Explanation of the Code

This Java class defines a `Game` object, which encapsulates information about a game, including its name, year of release, and the platforms on which it's available.

- **Imports**: It uses `java.util.*` and `java.io.*` for utility and input/output operations, though specific functionalities from these libraries aren't showcased in the portion of the code visible.

- **Attributes**:
  - `String name`: Stores the name of the game.
  - `int year`: Stores the year of release.
  - `String platforms`: Stores the platforms the game is available on.

- **Constructor**:
  - The constructor `Game(String name, String p, int year)` initializes the game object with a name, platforms, and a year.

- **Methods**:
  - `parsePlatforms(String s)`: A private method that splits the platforms string using a comma delimiter and returns an array of platforms.
  - `getPlatforms()`: This method is defined but not implemented in the current code.
  - `toString()`: Another method is defined but not implemented in the current code, typically used to return a string representation of the object.
  - `matchesYear(int y)`: Returns `true` if the game's year matches the input year `y`.
  - `matchesPlatform(String p)`: Returns `true` if the `platforms` string contains the substring `p`.
  - `matchesName(String str)`: Returns `true` if the game's name contains the substring `str`. 

This code is useful
Transcribed Image Text:```java import java.util.*; import java.io.*; public class Game{ String name; int year; String platforms; Game(String name, String p, int year){ this.name = name; platforms = p; this.year = year; } private String[] parsePlatforms(String s){ String[] platforms = s.split(", "); return platforms; } private String getPlatforms(){ } public String toString() { } public boolean matchesYear(int y){ if(this.year == y) return true; else return false; } public boolean matchesPlatform(String p){ if(this.platforms.contains(p)) return true; else return false; } public boolean matchesName(String str){ if(this.name.contains(str)) return true; else return false; } } ``` ### Explanation of the Code This Java class defines a `Game` object, which encapsulates information about a game, including its name, year of release, and the platforms on which it's available. - **Imports**: It uses `java.util.*` and `java.io.*` for utility and input/output operations, though specific functionalities from these libraries aren't showcased in the portion of the code visible. - **Attributes**: - `String name`: Stores the name of the game. - `int year`: Stores the year of release. - `String platforms`: Stores the platforms the game is available on. - **Constructor**: - The constructor `Game(String name, String p, int year)` initializes the game object with a name, platforms, and a year. - **Methods**: - `parsePlatforms(String s)`: A private method that splits the platforms string using a comma delimiter and returns an array of platforms. - `getPlatforms()`: This method is defined but not implemented in the current code. - `toString()`: Another method is defined but not implemented in the current code, typically used to return a string representation of the object. - `matchesYear(int y)`: Returns `true` if the game's year matches the input year `y`. - `matchesPlatform(String p)`: Returns `true` if the `platforms` string contains the substring `p`. - `matchesName(String str)`: Returns `true` if the game's name contains the substring `str`. This code is useful
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
InputStream
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education