Latest Activity In Study Groups

Join Your Study Groups

VU Past Papers, MCQs and More

We non-commercial site working hard since 2009 to facilitate learning Read More. We can't keep up without your support. Donate.


 

Please read the following instructions carefully before submitting assignment.

It should be clear that your assignment will not get any credit if:

 

  • The assignment is submitted after due date.
  • The submitted assignment does not open or file is corrupt.
  • Assignment is copied(partial or full) from any source (websites, forums, students, etc)
  • Code file is in any other format than .CPP

 

Objective:

 

The objective of this assignment is to learn, practice and understand practical usage of

  • Classes (Concept of Object Oriented Programming)
  • Multi Dimensional Arrays
  • Pointers
  • Functions

Guidelines:

 

  • Code should properly be indented and well commented.
  • Use only Dev-C++ for this assignment. If you are using any other tool then mention it at top of your code file as comments.
  • You are required to submit your solution files (.CPP and doc/docx) files as single zip file.  

 

Assignment Description

 

In this assignment, you are provided with a startup code attached with this assignment as “StartupCode.cpp”. Your job is to slightly modify this code as desired in this assignment.

First, you need to understand the working of the given code and execute it in Dev-C++. This is a mini Game, allowing three players to contest. Each Player will have to open three boxes from given one hundred boxes in 3 turns. There is a secret number in each box. In each turn, the secret number inside the selected box will add-up to the total score of player.  At the end, it will display the summary score of all players.

 

 

In this program, we have created a Player class which will keep record of individual player’s data i.e. name and score.  In main() function, we created three objects of Player class in the form of array. Doing this will allow three players to play the game.

A loop in main function is iterated to get name and score of three players. After getting player name and score, we are displaying result summary at the end of main function.

In this program, we have created five functions to perform all necessary tasks.

  • displayInformation() function is used to display the information about the game on top of output window.
  • fillBoard() function is taking a 2D array as argument and filling each element/box of array with random number from 1 to 100.  We are re-filling 2D array for each player. Element of this array are also referred as box.
  • displayBoard() function is also taking 2D array as argument and displaying box number from 1 to 100.

 

We are doing this for player to easily remember box number he/she want to open or already opened. It will show already opened box with character X indicating this box is already selected.

  • openBox() function is taking 2D array as argument. This function will get box number from player, add secret number stored at selected box into total score of player and set value of box to zero. Setting secret number of box to zero is allowing us to mark the box with X, so in next turn this box should not use again.    
  • sortPlayers() function is taking array of player and size of array as arguments. It is your task to write the code of this function.

 

Your Task

Your task is to slightly modify this code in order to show the Players result summary in sorted order as shown in the following snapshot (Highlighted in Red). You are required to write the implementation of sortPlayers() function to sort the players array in descending order on the base of player score.

Hint: The topic of bubble sort given in handouts will help you to perform your task easily.

You need to type in your own VU-ID (e.g. BC123456789) as one of the player’s name.

This will help us to verify that the code was written by you (not copied).

 

To understand the requirement clearly see the video file (sample_output.mp4) attached with this file. 

Sample working of the desired program is shown in attached video file “Sample_Output.mp4”.

 

Solution Guidelines

To get maximum marks you need to follow the guidelines given here.  

  • Completing implementation of sortPlayers() function to sort players array is the most important task in this assignment.
  • After completing required tasks, you are required to run the program and get screenshot of the sorted players score. To ensure originality, you are required to enter your VU-ID as one of the player’ name. Take screen shot of summary and paste it into MS word file.
  • Zip MS word and CPP file as single file and upload it. It is compulsory to send both CPP and Word files. If any of file will missing, you will lose a large portion of marks.

 

Hints:

For sorting of player array you need to understand the topic of bubble sort given in handouts.

If you understand the working of nested loops and accessing data member of class then you can easily sort the players array.  

Submission  

You are required to submit your solution files (.CPP and doc/docx) files as single zip file.

 

 

 

 

Views: 9408

Attachments:

Replies to This Discussion

check it agr yai thek ha to solution post krta hon phr

Attachments:

not working

My app is working....

v good alllll...

kch smjh nii aaya

Solution 

//Code of assignment for descending order  

void sortPlayers(Player players[], int size)
{
    
    Player Temp;
     int i, j;
     int flag = 1;
      for(i = 1; (i <= size) && flag; i++)
     {
          flag = 0;
          for (j=0; j < (size -1); j++)
         {
               if (players[j+1].getScore() > players[j].getScore())
              {
                    Temp = players[j];
                    players[j] = players[j+1];
                    players[j+1] = Temp;
                    flag = 1;
               }
          }
     }
     return;
}

Attachments:

thanks alot bro

its my pleasure bro

 Abbas thank u 

very very helpful material 

Allah apki her her mishkil asan frmay (ameen)

Ameeeeeen

u r wc

i need some information about final papers.

Total Marks:?

Total questions (subjective+objective MCQS)?

Passing marks?

Every programming language provides different features to make coding task easy. One of the main objectives is to keep things simple as possible. You have studied C++ in this course and have learnt many different concepts e.g. input/output, if-else statements, loops, arrays, functions etc.

Looping constructs are needed when a statement or a block of statement is repeatedly executed until a specific condition holds true. You have learned in this course that C++ provides three looping constructs; For Loop, While Loop and Do-while Loop.

For C++ designers, it is not easy to include a construct or structure while developing this computer language. On the other hand, it also increases the complexity for learners as languages with more construct are difficult to learn.

A language expert Mr. ABC objects the designers of C++ on the bases of following two arguments:

· A single looping construct is sufficient to cover all types of situations.

· Designers of C++ have not done any good with themselves and C++ programmers by making things complex with provision of three different looping constructs.

Your Task is to comment on the views of Mr. ABC. Clearly state your position in favor or against for each argument of Mr. ABC with justified reasons.

Instructions:

A concise, coherent and to the point answer is preferred over lengthy comment having irrelevant details. Answers, posted on regular Lesson's MDB or sent through email will NOT be considered in any case.
plzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz guide GDB Tomorrow is last date

RSS

© 2021   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service