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
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
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

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](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F2030e370-9e54-4afa-a021-9087227cf9ef%2F4b533c10-f127-4674-b0d1-e1d70b8d6078%2Ftsy56rj_processed.png&w=3840&q=75)
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

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps

Knowledge Booster
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.Recommended textbooks for you

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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education