Ошибка в программе: Track не содержит конструктор, который принимает 0 аргументов - C#
Формулировка задачи:
Ребята, имеется ошибка в программе: Track не содержит конструктор, который принимает аргументы 0, не могу понять в чём дело, заранее спасибо
Листинг программы
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- class Player : Track
- {
- public Player()
- {
- }
- public void Update()
- {
- Console.WriteLine("Добавлен новый трек");
- }
- }
- interface ente1
- {
- void AddObserver(Track observer);
- void RemoveObserver(Track observer);
- void Notify();
- }
- interface Track
- {
- void Update();
- }
- class Track
- {
- private string name;
- private string author;
- private string album;
- private int longest;
- private int rating;
- private int size;
- private string way;
- public Track(string name1, string author1, string album1, int longest1, int rating1, int size1, string way1)
- {
- name = name1;
- author = author1;
- album = album1;
- longest = longest1;
- rating = rating1;
- size = size1;
- way = way1;
- }
- public void setname(string name1)
- {
- name = name1;
- }
- public void setauthor(string author1)
- {
- author = author1;
- }
- public void setalbum(string album1)
- {
- album = album1;
- }
- public void setlongest(int longest1)
- {
- longest = longest1;
- }
- public void setrating(int rating1)
- {
- rating = rating1;
- }
- public void setsize(int size1)
- {
- size = size1;
- }
- public void setway(string way1)
- {
- way = way1;
- }
- public string getname()
- {
- return name;
- }
- public string getauthor()
- {
- return author;
- }
- public string getalbum()
- {
- return album;
- }
- public int getlongest()
- {
- return longest;
- }
- public int getrating()
- {
- return rating;
- }
- public int getsize()
- {
- return size;
- }
- public string getway()
- {
- return way;
- }
- class KONTAINER : ente1
- {
- public Track[] song;
- public Track[] music;
- int kol;
- int n;
- public KONTAINER(Track make)
- {
- kol = 0;
- n = 0;
- music = new Track[100];
- song = new Track[10];
- this.AddObserver(make);
- }
- public void set_n(int _n)
- {
- n = _n;
- }
- public void imput()
- {
- string name1;
- string author1;
- string album1;
- int longest1;
- int rating1;
- int size1;
- string way1;
- for (int i = 0; i < n; i++)
- {
- System.Console.WriteLine("Введите наименование:");
- name1 = System.Console.ReadLine();
- System.Console.WriteLine("Введите исполнителя:");
- author1 = System.Console.ReadLine();
- System.Console.WriteLine("Введите альбом:");
- album1 = System.Console.ReadLine();
- System.Console.WriteLine("Ввeдите длительность:");
- longest1 = Convert.ToInt32(System.Console.ReadLine());
- System.Console.WriteLine("Ввeдите рейтинг:");
- rating1 = Convert.ToInt32(System.Console.ReadLine());
- System.Console.WriteLine("Ввeдите размер:");
- size1 = Convert.ToInt32(System.Console.ReadLine());
- System.Console.WriteLine("Введите путь к файлу:");
- way1 = System.Console.ReadLine();
- music[i] = new Track(name1, author1, album1, longest1, rating1, size1, way1);
- }
- }
- public void AddObserver(Track make)
- {
- song[kol] = make;
- kol++;
- }
- public void RemoveObserver(Track make)
- {
- }
- public void Notify()
- {
- for (int i = 0; i < kol; i++)
- {
- song[i].Update();
- }
- }
- public void output(int n)
- {
- for (int i = 0; i < n; i++)
- {
- System.Console.WriteLine("{0}:{1} {2} {3} {4} {5} {6}", i, music[i].getname(), music[i].getauthor(), music[i].getalbum(), music[i].getlongest(), music[i].getrating(), music[i].getsize(), music[i].getway());
- }
- }
- public void newTrack(string name1, string author1, string album1, int longest1, int rating1, int size1, string way1)
- {
- music[n] = new Track(name1, author1, album1, longest1, rating1, size1, way1);
- n++;
- this.Notify();
- }
- public void sort_name()
- {
- for (int j = 0; j < n - 1; j++)
- {
- for (int i = j + 1; i < n; i++)
- {
- if (string.Compare(music[j].getname(), music[i].getname()) > 0)
- {
- Track s = music[i];
- music[i] = music[j];
- music[j] = s;
- }
- }
- }
- }
- public void sort_size()
- {
- bool bSott = true;
- do
- {
- bSott = false;
- for (int j = 0; j < n - 1; j++)
- {
- if (music[j].getsize() > music[j + 1].getsize())
- {
- Track s = music[j];
- music[j] = music[j + 1];
- music[j + 1] = s;
- }
- }
- } while (bSott);
- }
- class Lab_26
- {
- public static void Main()
- {
- string name1;
- string author1;
- string album1;
- int longest1;
- int rating1;
- int size1;
- string way1;
- int n;
- System.Console.WriteLine("Введите количество элементов массива:");
- n = Convert.ToInt32(System.Console.ReadLine());
- Player Track = new Player();
- KONTAINER mas = new KONTAINER(Track);
- mas.set_n(n);
- mas.imput();
- mas.output(n);
- System.Console.WriteLine("Добавление двух треков");
- System.Console.WriteLine("Введите имя:");
- name1 = System.Console.ReadLine();
- System.Console.WriteLine("Введите автора:");
- author1 = System.Console.ReadLine();
- System.Console.WriteLine("Введите альбом:");
- album1 = System.Console.ReadLine();
- System.Console.WriteLine("Введите длительность:");
- longest1 = Convert.ToInt32(System.Console.ReadLine());
- System.Console.WriteLine("Ввeдите рейтинг:");
- rating1 = Convert.ToInt32(System.Console.ReadLine());
- System.Console.WriteLine("Ввeдите размер:");
- size1 = Convert.ToInt32(System.Console.ReadLine());
- System.Console.WriteLine("Ввeдите путь:");
- way1 = System.Console.ReadLine();
- n++;
- System.Console.WriteLine("СООБЩЕНИЕ О ДОБАВЛЕНИИ");
- mas.newTrack(name1, author1, album1, longest1, rating1, size1, way1);
- mas.newTrack(name1, author1, album1, longest1, rating1, size1, way1);
- mas.output(n);
- System.Console.WriteLine("Сортировка по названию:");
- mas.sort_name();
- mas.output(n);
- System.Console.WriteLine("_________________________________:"); ;
- System.Console.WriteLine("Сортировка по размеру:");
- mas.sort_size();
- mas.output(n);
- }
- }
- }
- }
Решение задачи: «Ошибка в программе: Track не содержит конструктор, который принимает 0 аргументов»
textual
Листинг программы
- public Track(string name1, string author1, string album1, int longest1, int rating1, int size1, string way1)
- {
- name = name1;
- author = author1;
- album = album1;
- longest = longest1;
- rating = rating1;
- size = size1;
- way = way1;
- }
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д