Advertisement
Guest User

Untitled

a guest
Feb 13th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.84 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. class scheda {
  6. int codice;
  7. string marca;
  8. int prezzo;
  9. int pezziDisponibili;
  10. scheda* next;
  11.  
  12. public:
  13.  
  14. scheda(){
  15. cout<<"INSERIRE CODICE SCHEDA: ";
  16. cin>>codice;
  17. cout<<"MARCA: ";
  18. cin>>marca;
  19. cout<<"PREZZO: ";
  20. cin >> prezzo;
  21. cout<<"PEZZI DISPONIBILI: ";
  22. cin >>pezziDisponibili;
  23. }
  24. void setCodice(int a){codice=a;}
  25. void setMarca(string a){marca=a;}
  26. void setPrezzo(int a){prezzo=a;}
  27. void setPezzidispo(int a){pezziDisponibili=a;}
  28. int getCodice(){return codice;}
  29. string getMarca(){return marca;}
  30. int getPrezzo(){return prezzo;}
  31. int getPezzidispo(){return pezziDisponibili;}
  32. void setScheda(){
  33. cout<<"INSERIRE CODICE RAM: ";
  34. cin>>codice;
  35. cout<<"MARCA: ";
  36. cin>>marca;
  37. cout<<"PREZZO: ";
  38. cin >> prezzo;
  39. cout<<"PEZZI DISPONIBILI: ";
  40. cin >>pezziDisponibili;
  41. }
  42. void getScheda(){cout<<"CODICE: "<<codice<<" MARCA: "<<marca<<" PREZZO: "<<prezzo<<" PEZZI: "<<pezziDisponibili<<endl;}
  43.  
  44. scheda* getNext(){return next;}
  45. void setNext(scheda* succ){next=succ;}
  46.  
  47.  
  48.  
  49. };
  50.  
  51. void inserimentoTestaS(scheda* &testa){
  52.  
  53. scheda* nuovo=new scheda;
  54. nuovo->setNext(testa);
  55. testa=nuovo;
  56. }
  57.  
  58.  
  59. void visualizzaScheda(scheda* testa){
  60. if(testa==NULL){
  61. cout<<"LISTA VUOTA \n";
  62. }
  63. while(testa!=NULL){
  64. testa->getScheda();
  65. testa=testa->getNext();
  66.  
  67. }
  68.  
  69. }
  70.  
  71.  
  72. scheda* cercaScheda (scheda* testa){
  73.  
  74. int x=0;
  75. if(testa==NULL){cout<<"LISTA VUOTA \n";}
  76. else{
  77. cout<<"INSERISCI IL PREZZO PER CUI VUOI CERCARE: ";
  78. cin>>x;
  79. while(testa!=NULL){
  80. if(testa->getPrezzo()==x){
  81. cout<<"SCHEDA TROVATA! \n";
  82. testa->getScheda();
  83. return testa;
  84. }
  85. else {
  86. testa=testa->getNext();
  87. }
  88. }
  89. }
  90.  
  91.  
  92. return NULL;
  93. }
  94.  
  95. void modificaScheda(scheda* testa){
  96.  
  97. cercaScheda(testa)->setScheda();
  98.  
  99.  
  100. }
  101.  
  102.  
  103. class ram {
  104. int codice;
  105. string marca;
  106. int prezzo;
  107. int pezziDisponibili;
  108. ram* next;
  109.  
  110. public:
  111.  
  112. ram(){
  113. cout<<"INSERIRE CODICE RAM: ";
  114. cin>>codice;
  115. cout<<"MARCA: ";
  116. cin>>marca;
  117. cout<<"PREZZO: ";
  118. cin >> prezzo;
  119. cout<<"PEZZI DISPONIBILI: ";
  120. cin >>pezziDisponibili;
  121. }
  122. void setCodice(int a){codice=a;}
  123. void setMarca(string a){marca=a;}
  124. void setPrezzo(int a){prezzo=a;}
  125. void setPezzidispo(int a){pezziDisponibili=a;}
  126. int getCodice(){return codice;}
  127. string getMarca(){return marca;}
  128. int getPrezzo(){return prezzo;}
  129. int getPezzidispo(){return pezziDisponibili;}
  130. void setRam(){
  131. cout<<"INSERIRE CODICE RAM: ";
  132. cin>>codice;
  133. cout<<"MARCA: ";
  134. cin>>marca;
  135. cout<<"PREZZO: ";
  136. cin >> prezzo;
  137. cout<<"PEZZI DISPONIBILI: ";
  138. cin >>pezziDisponibili;
  139. }
  140. void getRam(){cout<<"CODICE: "<<codice<<" MARCA: "<<marca<<" PREZZO: "<<prezzo<<" PEZZI: "<<pezziDisponibili<<endl;}
  141.  
  142. ram* getNext(){return next;}
  143. void setNext(ram* succ){next=succ;}
  144.  
  145.  
  146.  
  147. };
  148.  
  149. void inserimentoTestaR(ram* &testa){
  150.  
  151. ram* nuovo=new ram;
  152. nuovo->setNext(testa);
  153. testa=nuovo;
  154. }
  155.  
  156.  
  157. void visualizzaRam(ram* testa){
  158. if(testa==NULL){
  159. cout<<"LISTA VUOTA \n";
  160. }
  161. while(testa!=NULL){
  162. testa->getRam();
  163. testa=testa->getNext();
  164.  
  165. }
  166.  
  167. }
  168.  
  169.  
  170. ram* cercaRam (ram* testa){
  171.  
  172. int x=0;
  173. if(testa==NULL){cout<<"LISTA VUOTA \n";}
  174. else{
  175. cout<<"INSERISCI IL PREZZO PER CUI VUOI CERCARE: ";
  176. cin>>x;
  177. while(testa!=NULL){
  178. if(testa->getPrezzo()==x){
  179. cout<<"RAM TROVATA! \n";
  180. testa->getRam();
  181. return testa;
  182. }
  183. else {
  184. testa=testa->getNext();
  185. }
  186. }
  187. }
  188.  
  189.  
  190. return NULL;
  191. }
  192.  
  193. void modificaRam(ram* testa){
  194.  
  195. cercaRam(testa)->setRam();
  196.  
  197.  
  198. }
  199.  
  200. class processore {
  201. int codice;
  202. string marca;
  203. int prezzo;
  204. int pezziDisponibili;
  205. processore* next;
  206.  
  207. public:
  208.  
  209. processore(){
  210. cout<<"INSERIRE CODICE PROCESSORE: ";
  211. cin>>codice;
  212. cout<<"MARCA: ";
  213. cin>>marca;
  214. cout<<"PREZZO: ";
  215. cin >> prezzo;
  216. cout<<"PEZZI DISPONIBILI: ";
  217. cin >>pezziDisponibili;
  218. }
  219. void setCodice(int a){codice=a;}
  220. void setMarca(string a){marca=a;}
  221. void setPrezzo(int a){prezzo=a;}
  222. void setPezzidispo(int a){pezziDisponibili=a;}
  223. int getCodice(){return codice;}
  224. string getMarca(){return marca;}
  225. int getPrezzo(){return prezzo;}
  226. int getPezzidispo(){return pezziDisponibili;}
  227. void setProcessore(){
  228. cout<<"INSERIRE CODICE PROCESSORE: ";
  229. cin>>codice;
  230. cout<<"MARCA: ";
  231. cin>>marca;
  232. cout<<"PREZZO: ";
  233. cin >> prezzo;
  234. cout<<"PEZZI DISPONIBILI: ";
  235. cin >>pezziDisponibili;
  236. }
  237. void getProcessore(){cout<<"CODICE: "<<codice<<" MARCA: "<<marca<<" PREZZO: "<<prezzo<<" PEZZI: "<<pezziDisponibili<<endl;}
  238.  
  239. processore* getNext(){return next;}
  240. void setNext(processore* succ){next=succ;}
  241.  
  242.  
  243.  
  244. };
  245.  
  246. void inserimentoTestaP(processore* &testa){
  247.  
  248. processore* nuovo=new processore;
  249. nuovo->setNext(testa);
  250. testa=nuovo;
  251. }
  252.  
  253. void visualizzaProcessori(processore* testa){
  254. if(testa==NULL){
  255. cout<<"LISTA VUOTA \n";
  256. }
  257. while(testa!=NULL){
  258. testa->getProcessore();
  259. testa=testa->getNext();
  260.  
  261. }
  262. }
  263.  
  264. processore* cercaProcessore (processore* testa){
  265.  
  266. int x=0;
  267. if(testa==NULL){cout<<"LISTA VUOTA \n";}
  268. else{
  269. cout<<"INSERISCI IL PREZZO PER CUI VUOI CERCARE: ";
  270. cin>>x;
  271. while(testa!=NULL){
  272. if(testa->getPrezzo()==x){
  273. cout<<"PROCESSORE TROVATO! \n";
  274. testa->getProcessore();
  275. return testa;
  276. }
  277. else {
  278. testa=testa->getNext();
  279. }
  280. }
  281. }
  282.  
  283.  
  284. return NULL;
  285. }
  286.  
  287. void modificaProcessore(processore* testa){
  288.  
  289. cercaProcessore(testa)->setProcessore();
  290.  
  291.  
  292. }
  293.  
  294. class PC {
  295. scheda s;
  296. ram r;
  297. processore p;
  298.  
  299. public:
  300.  
  301. };
  302.  
  303. int main() {
  304. processore* testa=NULL;
  305. for(int i=0;i<2;i++){
  306.  
  307. inserimentoTestaP(testa);
  308. }
  309.  
  310. visualizzaProcessori(testa);
  311. cercaProcessore(testa);
  312. modificaProcessore(testa);
  313. visualizzaProcessori(testa);
  314. return 0;
  315. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement