Documentos de Académico
Documentos de Profesional
Documentos de Cultura
-Código: 219114813.
CONCEPTO SI NO ACOMULACION
Bajé el trabajo de
internet o alguien me -100pts 0pts 0
lo pasó (aunque sea
de forma parcial)
Incluí el código fuente
en formato de texto +25pts 0pts 25
(sólo si funciona
cumpliendo todos los
requerimientos)
Incluí las impresiones
de pantalla (sólo si +25pts 0pts 25
funciona cumpliendo
todos los
requerimientos)
Incluí una portada que
identifica mi trabajo +25pts 0pts 25
(nombre, código,
materia, fecha, título)
CODIGO FUENTE:
Listexception.hpp
#ifndef LISTEXCEPTION_HPP_INCLUDED
#define LISTEXCEPTION_HPP_INCLUDED
#include<exception>
#include<string>
private:
std::string msg;
public:
return msg.c_str();
};
#endif
songNode.hpp
#ifndef SONGNODE_HPP_INCLUDED
#define SONGNODE_HPP_INCLUDED
#include <string>
class SongNode {
private:
std::string name;
std::string interpreter;
std::string autor;
std::string file;
int ranking;
SongNode* next;
SongNode* prev;
public:
SongNode();
SongNode(const &SongNode);
void setNext(SongNode*);
void setPrev(SongNode*);
};
#endif // SONGNODE_HPP_INCLUDED
songNode.cpp
#include "songNode.hpp"
return name;
return interpreter;
return autor;
return file;
return ranking;
}
return next;
return prev;
string cadenaDatos;
cadenaDatos+="\t| ";
cadenaDatos+=to_string(ranking);
cadenaDatos+="| ";
cadenaDatos+=name;
cadenaDatos+="| ";
cadenaDatos+=interpreter;
cadenaDatos+="| ";
cadenaDatos+=autor;
cadenaDatos+="| ";
cadenaDatos+=file;
cadenaDatos+="|";
return cadenaDatos;
name = n;
autor = a;
file = f;
ranking = r;
void SongNode::setNext(SongNode* n) {
next = n;
void SongNode::setPrev(SongNode* p)
prev = p;
Lista.hpp
#ifndef LIST_HPP_INCLUDED
#define LIST_HPP_INCLUDED
#include <string>
#include "songNode.hpp"
class List {
private:
SongNode* anchor;
public:
List();
List(const List&);
~List();
void deleteData(SongNode*);
void deleteAll();
List& operator = (const List&);
};
#endif // LIST_HPP_INCLUDED
Lista.cpp
#include "listexception.hpp"
#include "list.hpp"
SongNode* last(nullptr);
SongNode* newSongNode;
while(aux != nullptr) {
if(aux == nullptr)
if(last == nullptr)
anchor = newSongNode;
else
newSongNode ->setPrev(last);
last->setNext(newSongNode);
SongNode* aux(anchor);
while(aux != nullptr) {
if(aux == p)
return true;
aux = aux->getNext();
return false;
List::List() : anchor(nullptr) {}
copyAll(l);
List::~List() {
deleteAll();
*aux = e;
if(aux == nullptr)
if(p == nullptr) {
aux->setNext(anchor);
aux->setPrev(nullptr);
anchor = aux;
else {
aux->setNext(nullptr);
aux->setPrev(p);
p->setNext(aux);
if(op == 2) {
aux->setNext(anchor);
aux->setPrev(nullptr);
if(anchor != nullptr) {
anchor->setPrev(aux);
anchor = aux;
if(op == 3) {
aux->setPrev(p);
aux->setNext(p->getNext());
if(p->getNext() != nullptr) {
p->getNext()->setPrev(aux);
p->setNext(aux);
}
}
void List::deleteData(SongNode* p) {
if(!isValidPos(p))
p->getPrev()->setNext(p->getNext());
p->getNext()->setPrev(p->getPrev());
anchor = anchor->getNext();
delete p;
return anchor;
if(isEmpty())
return nullptr;
SongNode* aux(anchor);
while(aux->getNext() != nullptr) {
aux = aux->getNext();
return aux;
}
SongNode* List::getPrevPos(SongNode* p) const {
if(!isValidPos(p))
return nullptr;
return p->getPrev();
if(!isValidPos(p))
return nullptr;
return p->getNext();
SongNode* aux(anchor);
aux = aux->getNext();
return aux;
if(!isValidPos(p))
return p->toString();
int pos(0);
SongNode* aux(anchor);
string result;
while(aux != nullptr) {
aux = aux->getNext();
return result;
void List::deleteAll() {
SongNode* aux;
while(anchor != nullptr) {
aux = anchor;
anchor = anchor->getNext();
delete aux;
deleteAll();
copyAll(l);
return *this;
Menu.hpp
#ifndef MENU_HPP_INCLUDED
#define MENU_HPP_INCLUDED
#include"list.hpp"
class Menu {
private:
public:
void mainMenu(List&);
};
#endif // MENU_HPP_INCLUDED
Menu.cpp
#include<iostream>
#include <random>
#include <chrono>
#include <string>
#include"menu.hpp"
#include"songNode.hpp"
#include"list.hpp"
int i,ii,op,item;
string str;
SongNode theSong;
List::Position pos;
do {
cout<<theList.toString();
cout<<"\n\t MENU\n1)Inserta\t3)Anula\n2)Elimina\t4)Busqueda\n\t5)Salir\n\nSelecciona una opcion: ";
cin>>op;
system("cls");
auto semilla=chrono::system_clock::now().time_since_epoch().count();
default_random_engine generator(semilla);
switch(op) {
case 1: {
fflush(stdin);
cin>>op;
system("cls");
uniform_int_distribution<int>distribution(0,9999);///Ranking
theSong.setRanking(rnum);
cout<<"\nNombre: ";
fflush(stdin);
getline(cin,str);
theSong.setName(str);
cout<<"\nInterprete: ";
fflush(stdin);
getline(cin,str);
theSong.setInterpreter(str);
cout<<"\nAutor: ";
fflush(stdin);
getline(cin,str);
theSong.setAutor(str);
cout<<"\nArchivo.mp3: ";
fflush(stdin);
getline(cin,str);
theSong.setFile(str);
theList.addSong(theList.getLastPos(),theSong, op);
uniform_int_distribution<int>distribution(0,9999);///Ranking
theSong.setRanking(rnum);
cout<<"\nNombre: ";
fflush(stdin);
getline(cin,str);
theSong.setName(str);
cout<<"\nInterprete: ";
fflush(stdin);
getline(cin,str);
theSong.setInterpreter(str);
cout<<"\nAutor: ";
fflush(stdin);
getline(cin,str);
theSong.setAutor(str);
cout<<"\nArchivo.mp3: ";
fflush(stdin);
getline(cin,str);
theSong.setFile(str);
theList.addSong(theList.getFirstPos(),theSong, op);
}
if(op == 3) {
cout<<theList.toString();
fflush(stdin);
getline(cin, str);
theSong.setName(str);
theSong.setInterpreter(str);
pos = theList.findData(theSong);
uniform_int_distribution<int>distribution(0,9999);
theSong.setRanking(rnum);
cout<<"\nNombre: ";
fflush(stdin);
getline(cin,str);
theSong.setName(str);
cout<<"\nInterprete: ";
fflush(stdin);
getline(cin,str);
theSong.setInterpreter(str);
cout<<"\nAutor: ";
fflush(stdin);
getline(cin,str);
theSong.setAutor(str);
cout<<"\nArchivo.mp3: ";
fflush(stdin);
getline(cin,str);
theSong.setFile(str);
theList.addSong(pos,theSong, op);
system("cls");
break;
case 2:
cout<<theList.toString();
fflush(stdin);
getline(cin, str);
theSong.setName(str);
theSong.setInterpreter(str);
pos = theList.findData(theSong);
if(pos == nullptr)
theList.deleteData(pos);
system("cls");
break;
case 3:
theList.deleteAll();
//system("pause");
system("cls");
break;
case 4:
fflush(stdin);
cin>>op;
system("cls");
if(op == 1) {
fflush(stdin);
getline(cin,str);
theSong.setName(str);
pos = theList.findData(theSong);
if(pos == nullptr) {
else
cout<<"\n\n"<<theList.retrieve(pos);
if(op == 2) {
fflush(stdin);
getline(cin,str);
theSong.setInterpreter(str);
theSong.setName(str);
pos = theList.findData(theSong);
if(pos == nullptr) {
else
cout<<"\n\n"<<theList.retrieve(pos);
cout<<endl<<endl;
system("pause");
system("cls");
break;
case 5:
break;
default:
cout<<"Opcion invalida...\n\n";
system("pause");
system("cls");
while(op != 5);
system("cls");
cout<<"\n\n"<<"FINALIZANDO PROGRAMA..."<<"\n"<<endl;
Main.cpp
#include "menu.hpp"
int main() {
Menu theMenu;
List theList;
theMenu.mainMenu(theList);
return 0;