the library management system

34
The Library Management System for ACM Class 2011 10 ACM Xinchen Yan Nov. 15 th ,2011

Upload: ngoquynh

Post on 01-Jan-2017

243 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: The Library Management System

The Library Management Systemfor ACM Class 2011

10 ACM

Xinchen Yan

Nov. 15th,2011

Page 2: The Library Management System

Outline

• Understanding Requirements

• Manager Design Pattern

• Advanced Features

• Testing and Grading

• Implementation Hints

Page 3: The Library Management System

Understanding Requirements

• We provide several classes:

Book, User, Library, etc.

• That provide the functionality of the library system.

• You can build library management system on your own.

• Or build library management system by using our design.

• But you must follow some rules.

Page 4: The Library Management System

Rules

• If you try to build it on your own, please pay attention to CLI Standard and how we test your project.

• Do not submit project with unfinished methods.

Page 5: The Library Management System

Understanding Requirements

• To build the system as a whole

• What are the requirements?

• How to classify the requirements?

• CLASS

• Four Parts:

User, Book, Manager and Lib

Page 6: The Library Management System

A User’s perspective

• As a reader

- Login & Logout

- Change Password

- Borrow, Return, Renew and Reserve Books

- List all borrowed/reserved books

- Inquiry my penalty

• A reader use username to identify itself

Page 7: The Library Management System

A User’s perspective

• What’s the difference between teachers and students.

- The reader Type(TEACHER and STUDENT)

- The number of books that can be borrowed

- The Borrowed-Expired-Days

- Only teachers can reserve books.

Page 8: The Library Management System

A User’s perspective

• As an admin

- Login & Logout

- Change Password

- Create a new User/Book/Kind

- Update an existing User/Book/Kind

- Remove an existing User/Book/Kind

- List all Users

• An admin use username to identify itself as well

Page 9: The Library Management System

A Book’s Perspective

• Difficulties in understanding

• Book(something in the real world)

• Kind(a class/type of Book)

- “C++ Primer”(a Kind)

- My “C++ Primer ”( a Book)

Page 10: The Library Management System

A Book’s Perspective

• A Kind has the following attributes

- ISBN

- Book-name

- Authors(a series of authors)

• No two Kinds share the same ISBN

Page 11: The Library Management System

A Book’s Perspective

• A Book has the following attributes

- Kind

- Index

• No two Books share the same Index

• The process of reserving books

• Priority for reserving books

Page 12: The Library Management System

A Book’s Perspective

• Reserving priority

- Books have not been borrowed

- Books have been borrowed but have not been reserved by another User

Page 13: The Library Management System

Architecture overview

Library

ReaderManager

AdminManager

KindManager

BookManager

Student Teacher

Admin Kind BookReader

User

CLI

Page 14: The Library Management System

Manager Design Pattern

• The MDP puts functionality that considers all objects of a class into a separate managing object.

• Relation between Object and ObjectManager

- Reader vs. ReaderManager

- Admin vs. AdminManager

- Book vs. BookManager

- Kind vs. KindManager

Page 15: The Library Management System

Manager Design Pattern

Object

ObjectManager

CLI

Data(external file)

Page 16: The Library Management System

Manager Design Pattern

• The MDP helps with manipulating data

- create, update and remove

• In this Library Management System, MDP also hold a universal copy of corresponging data objects

– ObjectManager::loadAll called by Library::initialize

– ObjectManager::saveAll called by Library::finalize

Page 17: The Library Management System

Manager Design Pattern

• loadAll()

- load data(from external files) and store it in your Library System

• saveAll()

- save data(to external files)

• You may design your own file format

Page 18: The Library Management System

Advanced Features

• reorderResults

• searchLikeName

• searchByExpress

- Simple cases

- Powerful cases

“A” + “B”

“A” – “B”

Page 19: The Library Management System

Testing and Grading

• All programs will be tested automatically

• Provided 20 testcases

• Your score will be

score = testcases passed/20

• You need to design a class acting like Command-line interface

• Provided standard of CLI

Page 20: The Library Management System

Command-line interface

Page 21: The Library Management System

Standard of CLI

• Restart

• Authentication

• User-user

• User-book

• Time

• Query

Page 22: The Library Management System

Authentication

Page 23: The Library Management System

User-user

Page 24: The Library Management System

User-book

Page 25: The Library Management System

Time

Page 26: The Library Management System

Query

Page 27: The Library Management System

Implementation Hints

• Pointer• std::vector• Wide-character set

- wchar_t vs. char- std::wstirng vs. std::string- conversion

• File Operations- Check file existence- Read from a file & Write to a file

Page 28: The Library Management System

Implementation Hints

• Pointer vs. Reference

- How to create a new object

- How to remove an object

• std::vector

- Vectors are a kind of sequence container. As such, their elements are ordered following a strict linear sequence.

- http://www.cplusplus.com/reference/stl/vector/

Page 29: The Library Management System

Implementation Hints

• Vectors are good at:- Accessing individual elements by their position index (constant time).

- Iterating over the elements in any order (linear time).

- Add and remove elements from its end (constant amortized time).

Page 30: The Library Management System

Implementation Hints

• Conversion between string and wstring

• Find materials about character set and encodings by yourself.

• The following codes are supposed to be compiled under Windows(Win32 Platform)

– #include <windows.h>

Page 31: The Library Management System

inline string wtos(const wstring&w)

{

int len= WideCharToMultiByte(GetACP(), 0, w.c_str(), -1, NULL, 0, NULL, NULL);

char *buf= new char[len];

WideCharToMultiByte(GetACP(), 0, w.c_str(), -1, buf, len, NULL, NULL);

string s(buf);

delete[] buf;

return s;

}

Page 32: The Library Management System

inline wstring stow(const string &s)

{

int len= MultiByteToWideChar(GetACP(), 0, s.c_str(), -1, NULL, 0);

wchar_t*buf= new wchar_t[len];

MultiByteToWideChar(GetACP(), 0, s.c_str(), -1, buf, len);

wstringw(buf);

delete[] buf;

return w;

}

Page 33: The Library Management System

Check file existence

bool file_exists(string const &path)

{

fstreamf(path.c_str());

boolexists = f.is_open();

f.close();

return exists;

}

Page 34: The Library Management System

THANK YOU FOR LISTENING