page.java

来自「模拟网上购物系统」· Java 代码 · 共 103 行

JAVA
103
字号
package page;

public class page {
	
	private int pageSize=5;
	private int totalPage;
	private int totalRows;
	private int startRows;
	private int currentPage;
	
	public page(int _totalRows)
	{
		totalRows = _totalRows;
		totalPage = totalRows/pageSize;
		if(totalRows%pageSize != 0)
		{
			++totalPage;
		}
		startRows = 1;
		currentPage = 1;
	}
	
	public int getCurrentPage() {
		return currentPage;
	}
	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getStartRows() {
		return startRows;
	}
	public void setStartRows(int startRows) {
		this.startRows = startRows;
	}
	public int getTotalPage() {
		return totalPage;
	}
	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}
	public int getTotalRows() {
		return totalRows;
	}
	public void setTotalRows(int totalRows) {
		this.totalRows = totalRows;
	}
	
//	前一页
	public void Privous(int _currentPage)
	{ 
		if(_currentPage <= 1)
		{
			currentPage = 1;
		}
		else
		{
			currentPage = _currentPage-1;
		}
		startRows = (currentPage-1)*pageSize +1;
	}
	//后一页
	public void Next(int _currentPage)
	{ 
		if(_currentPage >= totalPage)
		{
			currentPage = totalPage;
		}
		else
		{
			currentPage = _currentPage+1;
		}
		startRows = (currentPage-1)*pageSize +1;
	}
	//首页
	public void First()
	{ 
		currentPage = 1;
		startRows = (currentPage-1)*pageSize +1;
	}
	//末页
	public void Last()
	{ 
	    currentPage = totalPage;
		startRows = (currentPage-1)*pageSize +1;
	}
	
	//选择
	public void Select(int _currentPage)
	{
		 currentPage = _currentPage;
	     startRows = (currentPage-1)*pageSize +1;
	}
	
	

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?