يشيولا قزر دمحم رمع دومحم: مسلاا: نشكس 3 Report 2: *The classes diagram

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

‫ محمود عمر محمد رزق الويشي‬: ‫االسم‬

3: ‫سكشن‬
◦ Report 2
Design the object model for a library management system. The model
should contain the entities in the system such as employees, books,
students (borrowers) etc. Draw the class diagram and give implementation
of the classes in C#

*The classes diagram


• implementation of the classes in C#
- class books :
class Book {
private int id;
private string name;
private string author;
private string dep_name;

public Book (int ID, string bookName, string Author, string


DepartmentName) {
id = ID;
name = bookName;
author = Author;
dep_name = DepartmentName;
}

public string getBook() {


return "Book ID is : " + id + '\n' +
"name is : " + name + '\n' + "Author is : " + author + '\n' +
"Department is : " + dep_name;
}
}

- class students :

class Student {
private string name;
private int grade;
private int id;
private int borrowed_books;
public Student (string Name, int Grade, int ID, int borrowedBooks) {
this.name = Name;
this.grade = Grade;
this.id = ID;
this.borrowed_books = borrowedBooks;
}

public string getStudent() {


return "Student name is : " + name + '\n' + "and his/her grade is : "
+ grade + '\n' +
"and id is : " + id + '\n' + "and number of borrowed books is : " +
borrowed_books;
}
}

- class employees :
class Employee {
private string name;
private string position;
private int number;
public Employee (string Name, string Position, int Number) {
this.name = Name;
this.position = Position;
this.number = Number;
}

public string getEmployee() {


return "Employee name is : " + name + '\n' + "and his/her position
is : " + position + '\n' +
"and number is : " + number;
}
}

* The program :

using System;

namespace App
{
class Program
{
static void Main(string[] args)
{
Console.Clear();
// Get Book Info
Console.WriteLine("Enter Book Info ");
Console.WriteLine("Enter Book id : ");
int book_id = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter Book name : ");
string book_name = Console.ReadLine();
Console.WriteLine("Enter Book Author : ");
string book_author = Console.ReadLine();
Console.WriteLine("Enter Book Department : ");
string book_dep_name = Console.ReadLine();
Book book = new Book(book_id, book_name, book_author,
book_dep_name);
// //
=========================================
===========================

Console.Clear();
// Get Student Info
Console.WriteLine("Enter Student Info ");
Console.WriteLine("Enter Student name : ");
string student_name = Console.ReadLine();
Console.WriteLine("Enter Student Grade : ");
int student_grade = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter Student id : ");
int student_id = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter Number of Student borrowed books : ");
int student_borrowed_books = Convert.ToInt32(Console.ReadLine());
Student student = new Student(student_name, student_grade,
student_id, student_borrowed_books);
// //
=========================================
===========================

Console.Clear();
// Get Employee Info
Console.WriteLine("Enter Employee Info ");
Console.WriteLine("Enter Employee name : ");
string employee_name = Console.ReadLine();
Console.WriteLine("Enter Employee Position : ");
string employee_position = Console.ReadLine();
Console.WriteLine("Enter Employee Number : ");
int employee_number = Convert.ToInt32(Console.ReadLine());
Employee employee = new Employee(employee_name,
employee_position, employee_number);
// //
=========================================
===========================

// Print Results
Console.Clear();
Console.WriteLine(book.getBook());
Console.WriteLine( "============================
==========" );
Console.WriteLine(student.getStudent());
Console.WriteLine( "============================
==========" );
Console.WriteLine(employee.getEmployee());

}
}
}

You might also like