Encapsulation in Java Implement getters and setters for the class in the code editor. Ask the user input for each attribute and use the setters to set the attributes.   Inputs 1. Game Name 2. Year Published 3. Game Publisher   Sample Output Enter game name: Genshin Impact Enter year published: 2020 Enter game publisher: Hoyoverse   Genshin Impact is published on 2020 by Hoyoverse

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter9: Using Classes And Objects
Section: Chapter Questions
Problem 2CP
icon
Related questions
Question

Encapsulation in Java

Implement getters and setters for the class in the code editor. Ask the user input for each attribute and use the setters to set the attributes.

 

Inputs

1. Game Name

2. Year Published

3. Game Publisher

 

Sample Output

Enter game name: Genshin Impact
Enter year published: 2020
Enter game publisher: Hoyoverse
 
Genshin Impact is published on 2020 by Hoyoverse.
1.
Encapsulation Practice I
by CodeChum Admin
Implement getters and setters for the class in the code editor.
Ask the user input for each attribute and use the setters to set
the attributes.
Inputs
1. Game Name
2. Year Published
3. Game Publisher
Sample Output
Enter game name: Genshin Impact
Enter year published: 2020
Enter game publisher: Hoyoverse
Genshin Impact is published on 2020 by Hoyoverse.
Main Java ←
1
2
3, class Game {
4
import java.util.Scanner;
5
6
7
private String name;
private int yearPublished;
private String publisher;
9
10 class Main [
11,
12
13
14 }
public static void main(String[] args) {
}
Java
✔
Test Cases
Constraints
O Constraint 1
The code must have getters.
O Constraint 2
The code must have setters.
Test Cases
O Test Case 1
Your Output
No Output
Expected Output
Enter game name: Genshin Impact
Enter year published: 2020
Enter game publisher: Hoyoverse
Genshin Impact is published on 2020 by Hoyoverse.
O Test Case 2
Your Output
No Output
Expected Output
Enter game name: Undertale
Enter year published: 2015
Enter game publisher: Toby Fox
Undertale is published on 2015 by Toby Fox.
Transcribed Image Text:1. Encapsulation Practice I by CodeChum Admin Implement getters and setters for the class in the code editor. Ask the user input for each attribute and use the setters to set the attributes. Inputs 1. Game Name 2. Year Published 3. Game Publisher Sample Output Enter game name: Genshin Impact Enter year published: 2020 Enter game publisher: Hoyoverse Genshin Impact is published on 2020 by Hoyoverse. Main Java ← 1 2 3, class Game { 4 import java.util.Scanner; 5 6 7 private String name; private int yearPublished; private String publisher; 9 10 class Main [ 11, 12 13 14 } public static void main(String[] args) { } Java ✔ Test Cases Constraints O Constraint 1 The code must have getters. O Constraint 2 The code must have setters. Test Cases O Test Case 1 Your Output No Output Expected Output Enter game name: Genshin Impact Enter year published: 2020 Enter game publisher: Hoyoverse Genshin Impact is published on 2020 by Hoyoverse. O Test Case 2 Your Output No Output Expected Output Enter game name: Undertale Enter year published: 2015 Enter game publisher: Toby Fox Undertale is published on 2015 by Toby Fox.
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Class
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT