P
P
Pavel Kononov2021-12-25 23:02:32
Java
Pavel Kononov, 2021-12-25 23:02:32

Creating, copying and displaying an array with the private modifier?

I welcome all Khabrovites.

The crux of the matter is this: there is some game, during the execution of which several players enter random values ​​in turn. Only 10 attempts each. It is necessary to store all the entered numbers in an array, for each player his own. Required with private access.

Here is my array private int[] numbers = new int[10]
Its setter is public void setNumbers(int numbers) {};

What's the catch: I understand the essence, but like a blind kitten, I can't figure out how to approach implementation.
It seems that there is an array, its setter, but I don’t understand how to cram the numbers entered by the player into the array. 11 hours in front of the monitor and deaf ...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
Jacen11, 2021-12-25
@Jacen11

at first I started writing a solution, but I didn’t understand something at
all that setNumbers is needed here, what is it? it takes one number, and there are 10 of them in the array. What is networking here at all?

I understand the point
judging by the curve of the wording, no, not really,
and if that numbers[0]= number; this is how the array element is filled. What exactly is the problem? what task?

D
Dmitry Roo, 2021-12-26
@xez

It is better to use not an array, but a List.
You, apparently, do not need a setter, but a method that will add a value to an array (or sheet).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question