Вы находитесь на странице: 1из 34

The Library Management System

for ACM Class 2011


10 ACM
Xinchen Yan
Nov. 15th,2011

Outline

Understanding Requirements
Manager Design Pattern
Advanced Features
Testing and Grading
Implementation Hints

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.

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.

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

A Users 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

A Users perspective
Whats 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.

A Users 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

A Books 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)

A Books Perspective
A Kind has the following attributes
- ISBN
- Book-name
- Authors(a series of authors)
No two Kinds share the same ISBN

A Books 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

A Books Perspective
Reserving priority
- Books have not been borrowed
- Books have been borrowed but have not
been reserved by another User

Architecture overview
Library
Reader
Manager
Student
Teacher

Admin
Manager

Kind
Manager

Book
Manager

Reader

Admin

Kind

Book

User

CLI

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

Manager Design Pattern

Object
ObjectManager
CLI
Data(external file)

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

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

Advanced Features
reorderResults
searchLikeName
searchByExpress
- Simple cases
- Powerful cases
A + B
A B

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

Command-line interface

Standard of CLI

Restart
Authentication
User-user
User-book
Time
Query

Authentication

User-user

User-book

Time

Query

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

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/

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).

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>

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;
}

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;
}

Check file existence


bool file_exists(string const &path)
{
fstreamf(path.c_str());
boolexists = f.is_open();
f.close();
return exists;
}

THANK YOU FOR LISTENING

Вам также может понравиться