#include <iostream>
#include "Book.h"
#include "ArrayList.h"
using namespace std;
void main(){
Book *book1 = new Book;
Book *book2 = new Book;
Book *book3 = new Book;
Book *book4 = new Book;
book1->num =1;
book1->price = 12;
book2->num = 2;
book2->price = 23;
book3->num = 3;
book3->price = 43;
ArrayList *arrayList = new ArrayList;
arrayList->add(book1);
arrayList->add(book2);
arrayList->add(book3);
//for(it=head;it->next!=nullptr;it=it->next)
arrayList->removeAt(0);
int i =0;
for(ArrayList*it=arrayList->head;it!=nullptr;it=it->next){
i++;
Book *book = new Book;
book = (Book*)it->data;
cout<<"书本"<<i<<"的编号为:"<<book->num<<endl;
cout<<"书本"<<i<<"的价格为:"<<book->price<<endl;
}
/*
for(int i=0;i<arrayList->size();i++){
Book *book = new Book;
book = (Book*)arrayList->get(i);
cout<<"书本"<<i<<"的编号为:"<<book->num<<endl;
cout<<"书本"<<i<<"的价格为:"<<book->price<<endl;
}
*/
}
/*
void main()
{
Base* base = NULL;
int choice = 0;
cout<<"请选择输入类型(1)学生(2)教师";
bool quit = false;
while(true){
cin>>choice;
switch (choice)
{
case 1:
base = new Person;
quit = true;
break;
case 2:
base = new Teacher;
quit = true;
break;
default:
cout<<"请输入1~2的数字";
break;
}
if(quit){
break;
}
}
//创建链表
Base* head;
head = base->createChain();
//展示链表信息
base->showChainInfo(head);
cout<<"请输入需要删除的id号码"<<endl;
int id;
cin>>id;
head =base->removeChainById(head,id);
//展示链表信息
base->showChainInfo(head);
float stature,weight;
cout<<"请输入id"<<endl;
cin>>id;
cout<<"请输入体重数值"<<endl;
cin>>weight;
cout<<"请输入身高数值"<<endl;
cin>>stature;
//插入链表
base->insertChain(head,id,stature,weight);
//展示链表信息
base->showChainInfo(head);
cout<<"请输入要查找的id号"<<endl;
cin>>id;
base->findChainById(head,id);
delete base;
}
*/
/*
//结构体链表
struct book
{
public:
int num;
float price;
struct book*next;
};
void main()
{
book a,b,c,*head,*p;
a.num =10000;
a.price = 18.7f;
head = &a;
a.next =&b;
b.num =20000;
b.price = 22.4f;
b.next = &c;
c.num = 40000;
c.price = 43.4f;
c.next = NULL;
p = head;
while(p!=NULL){
//首节点
cout<<"图书编号"<<p->num<<"图书价格"<<p->price<<endl;
//下一节点
p =p->next;
}
}
*/