OOP HomeWork

This commit is contained in:
e2hang
2025-08-11 00:01:30 +08:00
commit e8a5ca2363
119 changed files with 3187 additions and 0 deletions

23
oop_hw4/hw8/main.cpp Normal file
View File

@@ -0,0 +1,23 @@
#include <iostream>
#include "page.h"
using std::cin;
using std::cout;
using std::endl;
int main() {
Paginate pager(13);
for (int i = 1;i <= 13;i++)
{
//i<><69>ǰҳ<C7B0><D2B3>13<31><33>ҳ<EFBFBD><D2B3>
pager.setPage(i).show();
}
cout << "START MOVING...." << endl;
pager.setPage(5).show();
pager.next().show();
pager.prev().show();
//ֱ<>ӷ<EFBFBD>
pager.nextN().show();
pager.next().show();
pager.prevN().show();
return 0;
}

87
oop_hw4/hw8/page.cpp Normal file
View File

@@ -0,0 +1,87 @@
#include <iostream>
#include "page.h"
using std::cin;
using std::cout;
using std::endl;
void out(int n) {
switch (n)
{
case 1:
cout << "<EFBFBD><EFBFBD>ҳ 1+ 2 3 4 5 <20><> 13 <20><>ҳ" << endl;
break;
case 2:
cout << "<EFBFBD><EFBFBD>ҳ 1 2+ 3 4 5 <20><> 13 <20><>ҳ" << endl;
break;
case 3:
cout << "<EFBFBD><EFBFBD>ҳ 1 2 3+ 4 5 <20><> 13 <20><>ҳ" << endl;
break;
case 4:
cout << "<EFBFBD><EFBFBD>ҳ 1 2 3 4+ 5 <20><> 13 <20><>ҳ" << endl;
break;
case 5:
cout << "<EFBFBD><EFBFBD>ҳ 1 2 3 4 5+ <20><> 13 <20><>ҳ" << endl;
break;
case 6:
cout << "<EFBFBD><EFBFBD>ҳ 1 <20><> 6+ 7 8 9 10 <20><> 13 <20><>ҳ" << endl;
break;
case 7:
cout << "<EFBFBD><EFBFBD>ҳ 1 <20><> 6 7+ 8 9 10 <20><> 13 <20><>ҳ" << endl;
break;
case 8:
cout << "<EFBFBD><EFBFBD>ҳ 1 <20><> 6 7 8+ 9 10 <20><> 13 <20><>ҳ" << endl;
break;
case 9:
cout << "<EFBFBD><EFBFBD>ҳ 1 <20><> 6 7 8 9+ 10 <20><> 13 <20><>ҳ" << endl;
break;
case 10:
cout << "<EFBFBD><EFBFBD>ҳ 1 <20><> 6 7 8 9 10+ <20><> 13 <20><>ҳ" << endl;
break;
case 11:
cout << "<EFBFBD><EFBFBD>ҳ 1 <20><> 9 10 11+ 12 13 <20><>ҳ" << endl;
break;
case 12:
cout << "<EFBFBD><EFBFBD>ҳ 1 <20><> 9 10 11 12+ 13 <20><>ҳ" << endl;
break;
case 13:
cout << "<EFBFBD><EFBFBD>ҳ 1 <20><> 9 10 11 12 13+ <20><>ҳ" << endl;
break;
default:
cout << "Fail!" << endl;
break;
}
}
Paginate::Paginate() {
page_now = 0;
page_total = 0;
}
Paginate::Paginate(int n) {
page_total = n;
}
Paginate& Paginate::setPage(int n) {
page_now = n;
return *this;
}
Paginate& Paginate::next() {
page_now += 1;
return *this;
}
Paginate& Paginate::prev() {
page_now -= 1;
return *this;
}
Paginate& Paginate::nextN() {
page_now += 5;
return *this;
}
Paginate& Paginate::prevN() {
page_now -= 5;
return *this;
}
void Paginate::show() {
out(this->page_now);
}

20
oop_hw4/hw8/page.h Normal file
View File

@@ -0,0 +1,20 @@
#pragma once
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
class Paginate {
private:
int page_total;
int page_now;
public:
Paginate();
Paginate(int n);
Paginate& setPage(int n);
void show();
Paginate& next();
Paginate& prev();
Paginate& nextN();
Paginate& prevN();
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 393 KiB