{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Assignment_4.cpp - /= Name Practical.cpp Author Version...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
//============================================================================ // Name : Practical.cpp // Author : // Version : // Copyright : Your copyright notice //============================================================================ #include <iostream> #include <cstdlib> using namespace std; class Node { public: int value; Node *next; Node *prev; Node() { value=1; next=NULL; prev=NULL; } }; class List { public: Node *head; List() { head=NULL; } void Board(); int Dice(int score); // int CheckPosition(int scr); void Play(); }; void List::Board() { int i; for (i=1;i<102;i++) { Node *newNode= new Node(); if (head==NULL) head=newNode; else { Node *temp; temp=head; while (temp->next!=NULL) { temp=temp->next; } newNode->value=i; temp->next=newNode; newNode->prev=temp; cout<<temp->value<<"\t"; } } }
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
int List::Dice(int score) { int dice; dice=rand()%6 +1; cout<<"\nYou got "<<dice<<" Point !! "; score=score+dice; cout<<"Now you are at position "<<score; // return dice; switch(score) { case 98 :score=79; cout<<"you ran into a snake!"<<endl; break; case 93 :score=73; cout<<"you ran into a snake!"<<endl; break; case 87 :score=24; cout<<"you ran into a snake!"<<endl; break; case 62 :score=19; cout<<"you ran into a snake!"<<endl; break; case 54 :score=34; cout<<"you ran into a snake!"<<endl; break; case 17 :score=7; cout<<"you ran into a snake!"<<endl; break;
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern