Created
October 19, 2023 20:58
-
-
Save jpolivra/159c428dba09d6e7f912eaa4e6a48eea to your computer and use it in GitHub Desktop.
Receive patients with the following properties: Doctor name and Appoitment data. Then provide a way so the user can be able to search for a specific doctor patients data.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace abstract_data_types; | |
class Program | |
{ | |
class AppointmentDate | |
{ | |
public int Day; | |
public string Month; | |
public int Year; | |
} | |
class Patient | |
{ | |
public string Name; | |
public string DoctorName; | |
public AppointmentDate PatientAppointmentDate; | |
} | |
static void Main(string[] args) | |
{ | |
Patient[] Patients = new Patient[3]; | |
for(int i = 0; i < 3; i++) | |
{ | |
Patient x = new Patient(); | |
Console.Write($"\nPatient name {i + 1}.....:"); | |
x.Name = Console.ReadLine(); | |
Console.Write("Patient doctor..............:"); | |
x.DoctorName = Console.ReadLine(); | |
AppointmentDate xDate = new AppointmentDate(); | |
x.PatientAppointmentDate = xDate; | |
Console.WriteLine("Appointment date:"); | |
Console.Write("Appointment Day.....:"); | |
x.PatientAppointmentDate.Day = int.Parse(Console.ReadLine()); | |
Console.Write("Appointment Month...:"); | |
x.PatientAppointmentDate.Month = Console.ReadLine(); | |
Console.Write("Appointment Year...:"); | |
x.PatientAppointmentDate.Year = int.Parse(Console.ReadLine()); | |
Patients[i] = x; | |
} | |
Console.ReadKey(); | |
Console.Write("List doctor appointments (input doctor name): "); | |
string SearchValue = Console.ReadLine(); | |
foreach(Patient x in Patients) | |
{ | |
if(x.DoctorName == SearchValue) | |
{ | |
Console.Write($"\nPatient name: {x.Name}"); | |
Console.Write($"\nAppointment day: {x.PatientAppointmentDate.Day}"); | |
Console.Write($"\nAppointment month: {x.PatientAppointmentDate.Month}"); | |
Console.Write($"\nAppointment year: {x.PatientAppointmentDate.Year}"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment