Класс "Студент" и работа с конструкторами - C#
Формулировка задачи:
создал 3 класса в первых 2-х классах все понятно и все прекрасно работает
нужна помощь с 3 классом студен
на плюсах раньше та же проблема с конструкторами была
си-шарп только начали изучать классы и работу над ними
подскажите что не так в моими конструкторами ниже полный код
того что я уже написал
//1. Реализовать класс Student, который содержит поля для хранения фамилии, имени,
//отчества, даты рождения, домашнего адреса, телефонного номера. Также за каждым
//студентом закреплены 3 массива оценок – зачёты, курсовые работы, экзамены. Обязательные
//методы: 2-3 версии конструктора с параметрами, геттеры и сеттеры для всех полей, показ всех данных о студенте.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Classes
{
class Date
{
private int day;
private int month;
private int year;
public Date() : this(0, 0, 0)
{
}
public Date(int day, int month, int year)
{
int leapYear = year % 4;
if (day < 1 || day > 31)
{
Console.WriteLine("некорректная дата");
}
if (month < 1 || month > 12)
{
Console.WriteLine("некорректний месяц");
}
if (month == 2 && day > 29 - leapYear)
{
Console.WriteLine("некорректний дата месяца №2");
}
if (day > 30 + month % 2)
{
Console.WriteLine("некоректная дата високосный год");
}
SetDay(day);
SetMonth(month);
SetYear(year);
}
public void SetDay(int day)
{
this.day = day;
}
public void SetMonth(int month)
{
this.month = month;
}
public void SetYear(int year)
{
this.year = year;
}
public int GetDay()
{
return day;
}
public int GetMonth()
{
return month;
}
public int GetYear()
{
return year;
}
}
class PHONE
{
private int mob;
private int home;
private int work;
public PHONE() : this(0, 0, 0)
{
}
public PHONE(int mob, int home, int work)
{
SetMob(mob);
SetHome(home);
SetWork(work);
}
public void SetMob(int mob)
{
this.mob = mob;
}
public void SetHome(int home)
{
this.home = home;
}
public void SetWork(int work)
{
this.work = work;
}
public int GetMob()
{
return mob;
}
public int GetHome()
{
return home;
}
public int GetWork()
{
return work;
}
}
class Student
{
private string surname;
private string name;
private string patronymic;
private Date birthday;
private string adress;
private PHONE phone;
public void SetSurname(string surname)
{
this.surname = surname;
}
public void SetName(string name)
{
this.name = name;
}
public void SetPatronymic(string patronymic)
{
this.patronymic = patronymic;
}
public void SetBirthday(int day, int month, int year)
{
birthday.SetDay(day);
birthday.SetMonth(month);
birthday.SetYear(year);
}
public void SetAdress(string adress)
{
this.adress = adress;
}
public void SetPhone(int mob, int home, int work)
{
phone.SetMob(mob);
phone.SetWork(work);
phone.SetHome(home);
}
public string GetSurname()
{
return surname;
}
public string GetName()
{
return name;
}
public string GetPatronymic()
{
return patronymic;
}
public Date GetBirthday()
{
return birthday;
}
public string GetAdress()
{
return adress;
}
public PHONE GetPhone()
{
return phone;
}
//конструктор по умолчанию
public Student() : this("", "", "", , "", )
{
}
//2 - 3 версии конструктора с параметрами
public Student(string SN, string _Name, string _Patronymic, Date _Birthday, string _Adress)
{
}
public Student(string SN, string _Name, string _Patronymic)
{
}
//главный конструктор
public Student(string SN, string _Name, string _Patronymic, Date birthday, string _Adress, PHONE _Phone)
{
}
}
class Program
{
static void Main()
{
Date p = new Date(29, 2, 2316);
Console.WriteLine("{0}.{1}.{2}", p.GetDay(), p.GetMonth(), p.GetYear());
PHONE r = new PHONE(111111, 2222222, 33333333);
Console.WriteLine("{0}\n{1}\n{2}", r.GetMob(), r.GetHome(), r.GetWork());
Student s = new Student("Рубик", "Иван", "Петрович", (11, 12, 1887), "Посмитного 33", (23121, 431344, 42323));
Console.WriteLine("{0}\n{1}\n{2}", s.GetMob(), s.GetHome(), s.GetWork());
}
}
}Решение задачи: «Класс "Студент" и работа с конструкторами»
textual
Листинг программы
class Phone
{
private string _phoneNumber;
private string _phoneNumberType;
public string PhoneNumber
{
get
{
return _phoneNumber;
}
set
{
_phoneNumber = value;
}
}
public string PhoneNumberType
{
get
{
return _phoneNumberType;
}
set
{
_phoneNumberType = value;
}
}
}