KIT107 Programming Assignment

Assignment Help C/C++ Programming
Reference no: EM132633568

KIT107 Programming - University of Tasmania

Background

The AFL runs Australian Rules football. And the best team in the League is the Carlton football team.

A game in Australian rules comprises four quarters and in each quarter there can be a numerous shots for goal. Goals are worth six points, near misses ("points") are worth one, and shots in which the ball doesn't cross the goal line are worth 0. A score of 3 goals and 2 points is written as follows: 3 2 20.

You've been asked to track the score throughout a game, present the score at the end of a nominated quarter, draw a kind of histogram illustrating who has the lead and by how much, and finally, report the winning margin. See the section entitled Program Specification for details.

The data is organised by quarter (and is presented in the order the shot on goal is kicked). Each shot is identified by its team (a 0 or a 1) and the outcome: goal (6), point (1), nothing (0). You don't know how many shots on goal will occur during any given game. You should not score shots on goal which don't register a goal or a point, and all scoring shots should be stored in the order in which they are presented within their quarter.

A text file exists with the required data in it. I will give you code to read this into your program - but it may change. Based only on the information above (and not what is in the text file):

a Which underlying data structure (array or linked-list) will you use as a basis to model the collection of shots on goal for each of the quarters? In two-three sentences, justify your answer.

b In two-three sentences, explain the functionality required for your model of a collection of shots on goal. Which kind of abstract data type (binary tree, general tree, array, stack, priority queue, double-ended queue, set, ordered/unordered list, etc.) is appropriate for that functionality?

c Which underlying data structure (array or linked-list) will you use as a basis to model the collection of quarters? In two-three sentences, justify your answer.

d In two-three sentences, explain the functionality required for your model of the collection of quarters. Which kind of abstract data type (binary tree, general tree, array, stack, priority queue, double-ended queue, set, ordered/unordered list, etc.) is appropriate for that functionality?

To implement this you would need to define a type called one_quarter to implement your answer to (a) above to represent the collection of scores for a quarter, and also another type (called game) to implement your answer to (c) above to create a collection of one_quarters.

From this, the whole game could be defined as a global variable as follows:

game the_game;

Each of these two types can be defined as an array or a linked-list. Given the linked- list node from lectures:

struct node_int;
typedef struct node_int *node; struct node_int
{
void *data; node next;
};

you would either define game and/or one_quarter as a linked-list, e.g.
typedef node game;
and/or
typedef node one_quarter;

or you would define game and/or one_quarter as an array, e.g.
typedef one_quarter game[200];
and/or
typedef score one_quarter[200];
where you replace 200 by an appropriate upper-bound.

A score is defined as follows:

struct score_int { int quarter; int team;
int worth;
};
typedef struct score_int *score;

and you may assume the existence of all types (except one_quarter and game) and the following types and functions:

void init_score(score *sp, int q, int s); int get_quarter(score s);
int get_team(score s); int get_worth(score s);
void set_quarter(score s, int q); void set_team(score s, int t); void set_worth(score s, int w);
char *to_string(score s, const char **TEAMS);

A Visual Studio project is available on MyLO for you to download and use as a starting point. (If you are not using Visual Studio, then just grab the source files and data file from within the folder.) This starting point comprises the following files:
• node.h and node.c - the Node ADT from lectures as the building blocks for linked lists (should you need them). These files are complete;
• score.h and score.c - the Score ADT as specified above. These files are complete;
• assig_two220.c - the file which contains the main() function and other functions which implement the required task (including reading scores from the text file) and some constants, types, and global variables.

e You must complete assig_two220.c

Start by adding the one_quarter and game types from above. You may add other types, constants and variables as necessary.

Then, complete the missing functionality.

The project also contains the data file. This is just a text file which can be opened and read with most applications. It contains details of scores.

Program specification

First you must obtain the scores from a text file. The data must be stored in appropriate collections. At the top level there will be a collection of quarters (which comprise the game) and for each quarter there should be a collection of scores (stored in the order they are provided, i.e. first-in-first-out).

As a score is read from the file, the details should be checked. If it is not a goal or a point, then it should not be included in the collection. Otherwise it should be appended to the data for the quarter in which it occurs.

As the data are read in and stored in the collections, the following should occur:

i. The nature of the score (none, point, or goal), the team with the shot on goal, and the quarter in which it occurs should be displayed.

Each quarter should have a subtitle when it commences.

The game should have a title indicating the names of the two teams.

Once the data have been read in and stored in the collections, the following should occur:

ii. The user should enter a quarter number (1-4). Legal values below 1 should default to 1 and legal values above 4 should default to 4.

The scores for each team should then be shown, one line for each, for every quarter from 1 up to the quarter number entered (inclusive). The quarter should be shown as a sub-title, and the activity should have its own title.

iii. A kind of horizontal histogram should be shown which demonstrates the magnitude of the lead for the leading team following every score. The histogram should grow from the centre of the sreen, to the left when the first team is winning and to the right when the second team is winning.

Each team's name should be displayed above the graph and the activity should have its own title.

You may assume that the screen has a width of 80 characters and that the lead will never exceed 40 points.

iv. The final (winning) margin should be displayed.

For all of these, the formatting of your output should conform to the example shown below (with 4 entered for the score breakdown for ii).

Carlton v Losers
================

Starting Quarter 1

Score received: Quarter 1, a GOAL for Carlton
Score received: Quarter 1, a GOAL for Losers
Score received: Quarter 1, a Point for Carlton
Score received: Quarter 1, no score for Carlton
Score received: Quarter 1, a GOAL for Carlton
Score received: Quarter 1, no score for Losers
Score received: Quarter 1, no score for Carlton
Score received: Quarter 1, a GOAL for Losers
Score received: Quarter 1, no score for Carlton
Score received: Quarter 1, a Point for Losers

Score received: Quarter 1, no score for Losers Score received: Quarter 1, a GOAL for Losers Score received: Quarter 1, no score for Losers Score received: Quarter 1, no score for Carlton Score received: Quarter 1, no score for Carlton Score received: Quarter 1, no score for Losers Score received: Quarter 1, a Point for Losers

Starting Quarter 2

Score received: Quarter 2, no score for Carlton Score received: Quarter 2, a GOAL for Carlton Score received: Quarter 2, a Point for Carlton Score received: Quarter 2, a GOAL for Carlton Score received: Quarter 2, no score for Losers Score received: Quarter 2, no score for Carlton Score received: Quarter 2, no score for Carlton Score received: Quarter 2, no score for Losers Score received: Quarter 2, a Point for Carlton Score received: Quarter 2, no score for Losers Score received: Quarter 2, no score for Losers

Starting Quarter 3

Score received: Quarter 3, no score for Carlton
Score received: Quarter 3, no score for Losers
Score received: Quarter 3, a Point for Carlton
Score received: Quarter 3, a Point for Losers
Score received: Quarter 3, a Point for Losers
Score received: Quarter 3, no score for Carlton
Score received: Quarter 3, a GOAL for Carlton
Score received: Quarter 3, a Point for Losers
Score received: Quarter 3, a GOAL for Carlton
Score received: Quarter 3, a Point for Losers
Score received: Quarter 3, a GOAL for Carlton
Score received: Quarter 3, a Point for Losers
Score received: Quarter 3, no score for Losers
Score received: Quarter 3, no score for Carlton
Score received: Quarter 3, a Point for Carlton
Score received: Quarter 3, a GOAL for Losers
Score received: Quarter 3, a Point for Carlton
Score received: Quarter 3, a GOAL for Losers

Starting Quarter 4

Score received: Quarter 4, no score for Losers Score received: Quarter 4, a Point for Losers Score received: Quarter 4, no score for Carlton Score received: Quarter 4, no score for Losers Score received: Quarter 4, a GOAL for Carlton Score received: Quarter 4, no score for Losers Score received: Quarter 4, a Point for Carlton Score received: Quarter 4, a GOAL for Carlton Score received: Quarter 4, a Point for Losers Score received: Quarter 4, no score for Losers Score received: Quarter 4, no score for Losers Score received: Quarter 4, a Point for Carlton Score received: Quarter 4, no score for Carlton Score received: Quarter 4, a Point for Carlton


Scores up to Selected Quarter

Enter quarter number #4

Quarter 1
Carlton 2 1 13

Losers

Quarter

2 3 2 20
Carlton 4 3 27
Losers 3 2 20
Quarter Carlton 3
7
6
48
Losers 5 7 37
Quarter Carlton 4
9
9
63
Losers 5 9 39

Vertical Worm

Carlton Losers
******

*
*******
*

******
*******
*

******
*******
********
*******
******
************
***********
*****************
****************
**********************
*********************
**********************
****************
*****************
***********
**********
****************
*****************
***********************
**********************
***********************
************************

Final margin
The final margin is 24 points.

Program Style
The program you write for this assignment must be contained in five files as follows:
• score.h and score.c for managing a score;
• node.h and node.c for nodes of linked lists (if relevant);
• assig_two220.c for the main algorithm which controls the reading of the data, the management of the collections, the calculation of the results, and the

display of the information. No function should be longer than about half a screen-full or so of code.

Your program should follow the following coding conventions:
• const variable identifiers should be used as much as possible, should be written all in upper case and should be declared before all other variables;
• #defined symbols should only be used for constant values if const is inappropriate, for example the size of an array.
• global variables should be used sparingly with parameter lists used to pass non-global information in and out of functions.
• local variables should only be defined at the beginning of functions and their identifiers should start with a lower-case letter;
• every if and if-else statement should have a block of code (i.e. collections of lines surrounded by { and }) for both the if part and the else part (if used)
• every do, for, and while loop should have a block of code (i.e. {}s)
• the keyword continue should not be used;
• the keyword break should only be used as part of a switch statement;
• opening and closing braces of a block should be aligned;
• all code within a block should be aligned and indented 1 tab stop (or 4 spaces) from the braces marking this block;
• commenting:
o There should be a block of header comment which includes at least
» file name
» student name
» student identity number
» a statement of the purpose of the program
» date
o Each variable declaration should be commented
o There should be a comment identifying groups of statements that do various parts of the task
o Comments should describe the strategy of the code and should not simply translate the C into English

Attachment:- Programming.rar

Reference no: EM132633568

Questions Cloud

Relationship between clothing styles and developments : How do i write an informational essay about the relationship between clothing styles and developments in clothing creation.
What would General Mills book value of inventories : What would have been General Mills' book value of inventories at the end of fiscal year 2010 under this alternative cost flow assumption
What is the purpose of the documents : Analyze the rhetorical situation you will be participating in when writing a resume and cover letter. Consider the following:
Underlying structure of effective academic writing : What is the underlying structure of effective academic writing and responsible public discourse according to Gerald Graff
KIT107 Programming Assignment : KIT107 Programming Assignment Help and Solution, University of Tasmania - Assessment Writing Service - Draw a kind of histogram illustrating who has the lead
Legal psychology and victimization : This reading includes chapters addressing the issues of legal psychology and victimization.
Business analyst internship for dropbox : What is going on in the industry that might determine how you choose to persuade your audience? Are there any current events
What was alfred sisley most famous work : What was Alfred Sisley's most famous work? How was it related to the Impressionist movement?
Selection of the methodology and design for a study : How and why do the research questions drive the selection of the methodology and design for a study.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd