The task is pretty pointless in fact. Within the framework of this task, perhaps it makes sense to make an abstract class with the same abstract methods for outputting the elements of the array and searching for the maximum value, and then inherit two classes from it - a vector and a matrix and write your own implementations for each. If your teacher insists on the inheritance of the matrix from the vector, then he is an idiot - it can be done only with crutches.
Plus, besides, you wrote a very bad shitty implementation with hard-sized array sizes, passing the ready-made array to the constructor and the Console.ReadLine in the constructor, it’s good to get rid of it
UPD
then please enlighten me, maybe I’m really wrong, but how should I do it so that there is no hardcode in my case?
Enlighten:
First, you should not prescribe the size of the array directly in the cycle - this is a govnodische pure water. Your constructor takes a certain array of any length. Suppose an array that you pass to a constructor has not four, but three elements. This means that you will get an exception. In other words, nowhere and in no way do you indicate to a potential user of your class that its constructor expects not just an array, but an array of four elements. This is an extremely bad approach. Since you just need an array of four elements, then you do not need to pass it to the constructor at all, but you need to create it in this constructor. For example:
public Matrix() { arr = new int[4]; // сам массив arr должен быть объявлен в классе for (int i = 0; i < 4; i++) arr[i] = Int32.Parse(Console.ReadLine()); }
Secondly, if you really need to have four elements, then you do not need to register it in ten places. Enter a constant, assign it the desired value and use it in cycles. Then you do not need to change this magic number 4 wherever it occurs (and while puzzling, either you change the number itself, or it is some other "four"). For example:
public class Matrix { private const int Size = 4; private int[] arr = new int[Size]; public Matrix() { for (int i = 0; i < size; i++) arr[i] = Int32.Parse(Console.ReadLine()); } }
Third, you don't need to use any Console.ReadLine in the constructor. Because console input has no place in the constructor at all, and most importantly, because your class should not depend on the Console class. Moreover, if the Convert method cannot convert a string to a number (and this is quite a frequent case if, say, the user enters what the hell knows), then you will get an exception, which you do not process again. If you need to somehow initialize the array, then either transfer four separate values to the constructor from the outside, or initialize it with random numbers. The array transfer option is not very good, I wrote about it above. It requires checking that the array contains exactly 4 elements, and, most importantly, does not tell the user about it.
Fourth, take a look at your methods - they all accept an array of integers, and in fact do nothing with it. Why? You should find the greatest values of your vector, and not just what array, obtained as a parameter. Remove them from the parameters and use the internal private variable.