知识付费源码知识付费⽹站搭建知识付费⼩程序源码
  设计⼀个在线教育知识付费源码系统(⾯向对象设计)。
  解决⽅案:假设我们想要设计⼀个基本的内容付费阅读系统并带⼩程序,提供以下功能:
  ·查知识数据库并阅读付费内容;
  ·⽤户成员的创建和扩展;
  ·基于⽤户分级权限管理,并且这个⽤户只能获权后阅读。
  完整源码:p
  类OnlineReaderSystem代表程序的主体。我们可以实现这个类,让它存储有关所有涉及⽤户管理的权限分级的信息,并刷新显⽰,但这会使这个类变得相当庞⼤。相反,我们选择将这些组件拆分成Library、UserManager和Display类。
  类:
  1、⽤户
  2、知识
  3、UserManager
  4、OnlineReaderSystem
  代码如下:
  import java.util.HashMap;
  /*
  * This class represents the system
  */
  class OnlineReaderSystem {
  private Library library;
  private UserManager userManager;
  private Display display;
  private Book activeBook;
  private User activeUser;
  public OnlineReaderSystem()
  {
  userManager = new UserManager();
  library = new Library();
  display = new Display();
  }
  public Library getLibrary()
  {
  return library;
  }
  public UserManager getUserManager()
  {
  return userManager;
  }
  public Display getDisplay()
  {
  return display;
  }
  public Book getActiveBook()
  {
  return activeBook;
  }
  public void setActiveBook(Book book)
  {
  activeBook = book;
  display.displayBook(book);
  }
  public User getActiveUser()
  {
  return activeUser;
  }
  public void setActiveUser(User user)
  {
  activeUser = user;
  display.displayUser(user);
  }
  }
  /*
  * We then implement separate classes to handle the user   * manager, the library, and the display components
  */
  /*
  * This class represents the Library which is responsible   * for storing and searching the books.
  */
  class Library {
  private HashMap<Integer, Book> books;
  public Library()
  {
  books = new HashMap<Integer, Book>();
  }
  public Boolean addBook(int id, String details, String title)  {
  if (ainsKey(id)) {
  return false;
  }
  Book book = new Book(id, details, title);
  books.put(id, book);
  books.put(id, book);
  return true;
  }
  public Boolean addBook(Book book)
  {
  if (Id())) {
  return false;
  }
  books.Id(), book);
  return true;
  }
  public boolean remove(Book b)
  {
  return Id());
  }
  public boolean remove(int id)
  {
  if (!ainsKey(id)) {
  return false;
  }
  ve(id);
  return true;
  }
  public Book find(int id)
  {
  (id);
  }
  }
  /*
  * This class represents the UserManager which is responsible   * for managing the users, their membership etc.
  */
  class UserManager {
  private HashMap<Integer, User> users;
不付费免费网站  public UserManager()
  {
  users = new HashMap<Integer, User>();
  }
  public Boolean addUser(int id, String details, String name)
  {
  if (ainsKey(id)) {
  return false;
  }
  User user = new User(id, details, name);
  users.put(id, user);
  return true;
  }
  public Boolean addUser(User user)
  {
  if (Id())) {
  return false;
  }
  users.Id(), user);
  return true;
  }
  public boolean remove(User u)
  {
  return Id());
  }
  public boolean remove(int id)
  {
  if (ainsKey(id)) {
  return false;
  }
  ve(id);
  return true;
  return true;
  }
  public User find(int id)
  {
  (id);
  }
  }
  /*
  * This class represents the Display, which is responsible
  * for displaying the book, it's pages and contents. It also
  * shows the current user. * It provides the method
  * turnPageForward, turnPageBackward, refreshPage etc.  */
  class Display {
  private Book activeBook;
  private User activeUser;
  private int pageNumber = 0;
  public void displayUser(User user)
  {
  activeUser = user;
  refreshUsername();
  }
  public void displayBook(Book book)
  {
  pageNumber = 0;
  activeBook = book;
  refreshTitle();
  refreshDetails();
  refreshPage();
  }
  public void turnPageForward()
  {
  pageNumber++;
  System.out.println("Turning forward to page no " +
  pageNumber + " of book having title " +
  Title());
  refreshPage();
  }
  public void turnPageBackward()
  {
  pageNumber--;
  System.out.println("Turning backward to page no " +
  pageNumber + " of book having title " +
  Title());
  refreshPage();
  }
  public void refreshUsername()
  {
  /* updates username display */
  System.out.println("User name " + Name() +  " is refreshed");
  }
  public void refreshTitle()
  {
  /* updates title display */
  System.out.println("Title of the book " +
  Title() + " refreshed");
  }
  public void refreshDetails()
  {
  /* updates details display */
  System.out.println("Details of the book " +
  Title() + " refreshed");
  }
  public void refreshPage()
  {
  {
  /* updated page display */
  System.out.println("Page no " + pageNumber + " refreshed");  }
  }
  /*
  * The classes for User and Book simply hold data and
  * provide little functionality.
  * This class represents the Book which is a simple POJO
  */
  class Book {
  private int bookId;
  private String details;
  private String title;
  public Book(int id, String details, String title)
  {
  bookId = id;
  this.details = details;
  this.title = title;
  }
  public int getId()
  {
  return bookId;
  }
  public void setId(int id)
  {
  bookId = id;
  }
  public String getDetails()
  {
  return details;
  }
  public void setDetails(String details)
  {
  this.details = details;
  }
  public String getTitle()
  {
  return title;
  }
  public void setTitle(String title)
  {
  this.title = title;
  }
  }
  /*
  * This class represents the User which is a simple POJO
  */
  class User {
  private int userId;
  private String name;
  private String details;
  public void renewMembership()
  {
  }
  public User(int id, String details, String name)
  {
  this.userId = id;
  this.details = details;
  this.name = name;
  }
  public int getId()
  {
  return userId;
  }
  public void setId(int id)

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。