1. Homepage
  2. Programming
  3. CS 162 Assignment #2 The Hooping Catalog

CS 162 Assignment #2 The Hooping Catalog

Engage in a Conversation
Oregon State UniversityCS 162Introduction to Computer Science IIC++The Hooping Catalog

CS 162 Assignment #2 The Hooping Catalog CourseNana.COM

Design Document due: Sunday, 10/22/2023, 11:59 p.m. (Canvas) CourseNana.COM

Assignment due: Sunday, 10/29/2023, 11:59 p.m. (TEACH) CourseNana.COM

Demo period: Monday, 10/30/2023 – Friday 11/10/2023, 11:59 p.m (in person) CourseNana.COM

CourseNana.COM

Goals: CourseNana.COM

·       Practice good software engineering design principles: CourseNana.COM

o   Design your solution before writing the program CourseNana.COM

o   Develop test cases before writing the program CourseNana.COM

·       Practice pointers, arrays, dynamic memory usage, and structs CourseNana.COM

·       Use file I/O to read from and write to files CourseNana.COM

·       Practice file separation and create Makefile CourseNana.COM

·       Use functions to modularize code to increase readability and reduce repeated code CourseNana.COM

  CourseNana.COM


CourseNana.COM

Problem Statement: CourseNana.COM

The Beaver Basketball Association (BBA) has recently added a lot of new teams and players to their catalog. We have witnessed some players showcasing exceptional skills on the court. However, it has become progressively challenging for the coaching staff to locate specific players they wish to draft onto their teams. CourseNana.COM

In order to alleviate these issues, the league's management has appointed you to develop a basketball team catalog program that will streamline access control and simplify the process of scouting for talented players. CourseNana.COM

To simplify your task, the management team has provided you with the teams’ profile information. These come in the form of a text file: teams.txt(NOTE: The filename provided from the user inputs should not be hardcoded in your program!)  CourseNana.COM

The teams.txt file contains a list of BBA’s teams and their players. This file will give you the team and player information that your program will organize and display. CourseNana.COM


CourseNana.COM

Get the skeleton code CourseNana.COM

Upload/download the start code for this lab onto flip.engr.oregonstate.edu:
wget https://classes.engr.oregonstate.edu/eecs/fall2023/cs162-010/assignments/asm2.zip CourseNana.COM

Then, unzip it: unzip asm2.zip

CourseNana.COM

Requirements: CourseNana.COM

1.     User inputs: CourseNana.COM

When starting the program, the user will be prompted for one input: the name of the file that contains the information about teams and included players. If the user does not provide the name of existing file, the program should print out an error message and quit. CourseNana.COM

  CourseNana.COM

2.     Searching and Printing: CourseNana.COM

Once the user provided the correct file, they should be prompted with a list of different ways to display the team after the search and player information. After the user has chosen an option, they should be asked if they want the information printed to the screen or written to a file. If they choose to write to a file, they should be prompted for a file name. If the file name already exists, the information should be appended to the file. If the file name does not exist, a file should be created, and the information should be written to the file. CourseNana.COM

  CourseNana.COM

3.     Available Options: CourseNana.COM

o   Search team by its name: If the user picks this option, the user will then be prompted for a valid team name. If found, the team that has the exact same name will be displayed. When they are displayed, you should print (or write to file) the entire information of the team and its players in a readable format. CourseNana.COM

  CourseNana.COM

o   Display the top scorer of every team: If the user picks this option, the player who score the most points per game of every team will be displayed (one player per team, if there is a tie, print any one of them). When they are displayed, you should print/write to file with the following information in a readable format: CourseNana.COM

o   Team name CourseNana.COM

o   Player name CourseNana.COM

o   Points per game of the player CourseNana.COM

  CourseNana.COM

o   Search players by nationality: If the user picks this option, the user will then be prompted for a valid nationality. The players (of all the teams) that have the typed nationality will be displayed. Once they are displayed, you should print/write to file the player’s name and their age. CourseNana.COM

  CourseNana.COM

o   Quit: The program will exit. CourseNana.COM

  CourseNana.COM

4.     Your program should continue running until the user chooses to quit. CourseNana.COM

  CourseNana.COM


CourseNana.COM

Required Structs: CourseNana.COM

The following structs are required in your program. They will help organize the information that will be read in (or derived) from the files. You cannot modify, add, or take away any part of the struct. CourseNana.COM

1.     The team struct will be used to hold information from the teams.txt file. This struct holds information about a team. CourseNana.COM

struct Team {
  string name;            //name of the team
  string owner;           //owner of the team
  int market_value;       //market value of the team
  int num_player;         //number of players in the team
  struct Player *p;       //an array that holds all players
  float total_ppg;        //total points per game
};
CourseNana.COM

2.     The player struct will also be used to read in information from the teams.txt file. This struct holds information about a player. CourseNana.COM

struct Player {
  string name;            //name of the player
  int age;                //age of the player
  string nation;               //nationality of the player
  float ppg;              //points per game of the player
  float fg;               //field goal percentage
};
CourseNana.COM

  CourseNana.COM


CourseNana.COM

Required Functions: CourseNana.COM

You must implement the following functions in your program. You are not allowed to modify these required function declarations in any wayNote: it is acceptable if you choose to add additional functions (but you must still include the required functions). CourseNana.COM

1.     This function will dynamically allocate an array of teams (of the requested size): CourseNana.COM

Team * create_teams(int); CourseNana.COM

2.     This function will fill a single team struct with information that is read in from teams.txtHint: “ifstream &” is a reference to a filestream object. You will need to create one and pass it into this function to read from the teams.txt file. CourseNana.COM

Parameters: Team*  –  pointer to the Team array CourseNana.COM

                     int – index of the Team in the array CourseNana.COM

                     ifstream& – input file to get team/player information from CourseNana.COM

void populate_team_data(Team *, int, ifstream &); CourseNana.COM

3.     This function will dynamically allocate an array of players (of the requested size): CourseNana.COM

Player * create_players(int); CourseNana.COM

4.     This function will fill a single player struct with information that is read in from teams.txt. CourseNana.COM

Parameters: Player*  –  pointer to the player array CourseNana.COM

                     int – index of the player in the array CourseNana.COM

                     ifstream& – input file to get player information from CourseNana.COM

void populate_player_data(Player *, int, ifstream &); CourseNana.COM

5.     You need to implement a function that will delete all the memory that was dynamically allocated. CourseNana.COM

void delete_info(Team *, int); CourseNana.COM

  CourseNana.COM

Required Input File Format: CourseNana.COM

Your program must accommodate the file formats as specified in this section. CourseNana.COM

·       The teams.txt file information will be provided in sets (corresponding to each team). CourseNana.COM

·       Each team will be accompanied by a listing of the players inside. CourseNana.COM

·       The teams.txt file will have the following pattern: CourseNana.COM

<total number of teams in file>
<name of the first team> <owner> <market value> <number of players in team>
<name of player> <age> <nationality> <points per game> <field goal percentage>
<name of player> <age> <nationality> <points per game> <field goal percentage>
<name of player> <age> <nationality> <points per game> <field goal percentage>
...
<name of the second team> <owner> <market value> <number of players in team>
<name of player> <age> <nationality> <points per game> <field goal percentage>
<name of player> <age> <nationality> <points per game> <field goal percentage>
<name of player> <age> <nationality> <points per game> <field goal percentage>
<name of player> <age> <nationality> <points per game> <field goal percentage>
...
<name of the third team> <owner> <market value> <number of players in team>
<name of player> <age> <nationality> <points per game> <field goal percentage>
<name of player> <age> <nationality> <points per game> <field goal percentage>
CourseNana.COM

An example teams.txt file is provided in the skeleton code.   CourseNana.COM

  CourseNana.COM

  CourseNana.COM


CourseNana.COM

Required files: CourseNana.COM

You are expected to modularize your code into a header file (.h), an implementation file (.cpp), and a driver file (.cpp). CourseNana.COM

1.     catalog.h: This header file contains all struct declarations and function prototypes CourseNana.COM

2.     catalog.cpp: This implementation file contains all function definitions CourseNana.COM

3.     run_catalog.cpp: This driver file contains the main function CourseNana.COM

4.     A makefile is required CourseNana.COM

  CourseNana.COM


CourseNana.COM

Example Operation CourseNana.COM

The following snippet of text shows an example implementation of the program. Note that this example does not illustrate all required behavior. You must read this entire document to ensure that you meet all of the program requirements. (User inputs are highlighted) CourseNana.COM

<Note: This example output is only intended to illustrate the program operation. Your values will be different.> CourseNana.COM

$ ./catalog_prog
Enter the team info file name: teams.txt
CourseNana.COM


Which option would you like to choose?
1. Search team by its name
2. Display the top scorer of each team
3. Search players by nationality
4. Quit
Your Choice: 2
CourseNana.COM

How would you like the information displayed?
1. Print to screen (Press 1)
2. Print to file (Press 2)
Your Choice: 1
CourseNana.COM

Thunder_Strikers: Alex_Johnson 22.5
Phoenix_Flames: James_Bryant 38.3
Blizzard_Bears: Ethan_Davis 26.8
Galaxy_Guardians: Dame_Dolla 32.1


Which option would you like to choose?
1. Search team by its name
2. Display the top scorer of each team
3. Search players by nationality
4. Quit
Your Choice: 1
CourseNana.COM

How would you like the information displayed?
1. Print to screen (Press 1)
2. Print to file (Press 2)
Your Choice: 2
CourseNana.COM

Please provide desired filename: teamname.txt

Enter the team’s name:
 Galaxy_Guardians CourseNana.COM

Appended requested information to file.

Which option would you like to choose?
1. Search team by its name
2. Display the top scorer of each team
3. Search players by nationality
4. Quit
Your Choice: 3

How would you like the information displayed?
1. Print to screen (Press 1)
2. Print to file (Press 2)
Your Choice: 1
CourseNana.COM

Enter the player’s nationality: Sweden CourseNana.COM

Sophia_Anderson  27
Andreas_Larsson  29

Which option would you like to choose?
1. Search team by its name
2. Display the top scorer of each team
3. Search players by nationality
4. Quit
Your Choice: 4
CourseNana.COM

Bye! CourseNana.COM


Extra credit options:
CourseNana.COM

1.     (10 pts) Add an additional menu option: Sort teams by total points per game. If the user picks this option, the teams will be sorted in descending order by total points per game. The total points per game of a team is the sum of each player’s points per game within the team. Once sorted, you should print/write to file the team’s name and the corresponding total points per game. CourseNana.COM

Additional requirements: CourseNana.COM

a.     For your option, you CANNOT use any built-in sorting function. CourseNana.COM

b.     When sorting, either modifying the original Team array, or applying sorting on a copy of the array, is acceptable. CourseNana.COM

  CourseNana.COM

2.     (10 pts) Simulate a basketball game. Add another menu option: Simulate a game. In this option, the user will simulate a multiplayer basketball shooting game (from assignment 1). You need to modify your program from assignment 1, and combine it with assignment 2 to complete this option.
Additional requirements:
CourseNana.COM

a.     Separate your assignment 1 into 3 files: interface (game.h), implementation (game.cpp), and main (main.cpp). All gaming functionalities should be implemented in game.cpp, and game.h should be included in catalog.cpp to support this additional option. CourseNana.COM

In other words: CourseNana.COM

if you compile game.cpp and main.cpp, it should run your assignment 1; CourseNana.COM

if you compile game.cpp, catalog.cpp, and run_catalog.cpp, your assignment 2 will be run.
(Hint: consider adding more targets into
makefile) CourseNana.COM

  CourseNana.COM

b.     Prompt the user for two valid player names from the catalog. i.e., Each player’s name should exist in teams.txt, otherwise you need to re-prompt. CourseNana.COM

(Note: if your program supports N players instead of two, then prompt for N followed by N player names) CourseNana.COM

  CourseNana.COM

c.     Instead of using the requirement “50% chance of successfully making the shot” from assignment 1, simulate the game using each player’s field goal percentage. For example, if a player Dame_Dolla’s field goal percentage is 0.63, then their chance of making the shot is 63%. CourseNana.COM

(Hint: rand() % 101 à returns a random value from 0-100) CourseNana.COM

  CourseNana.COM

d.     Declare the winner with player name and their total score. CourseNana.COM

  CourseNana.COM

  CourseNana.COM

Programming Style/Comments CourseNana.COM

In your implementation, make sure that you include a program header. Also ensure that you use proper indentation/spacing and include comments! Below is an example header to include. Make sure you review the style guidelines for this class , and begin trying to follow them, i.e. don’t align everything on the left or put everything on one line! CourseNana.COM

/****************************************************** CourseNana.COM

** Program: catalog.cpp CourseNana.COM

** Author: Your Name CourseNana.COM

** Date: 10/30/2023 CourseNana.COM

** Description:  CourseNana.COM

** Input: CourseNana.COM

** Output: CourseNana.COM

******************************************************/ CourseNana.COM

  CourseNana.COM


CourseNana.COM

Design Document – Due Sunday 10/22/2023, 11:59pm on Canvas CourseNana.COM

Refer to the Design Template CourseNana.COM

  CourseNana.COM

See design template (.docx or .pdf) for assignment 2. CourseNana.COM

NOTE: To receive full credits, you will need to answer every question in the provided tempelate. CourseNana.COM

Electronically submit your Design Doc (.pdf file!!!) by the design due date, on Canvas. CourseNana.COM

  CourseNana.COM

  CourseNana.COM

Program Code – Due Sunday, 10/29/2023, 11:59pm on TEACH CourseNana.COM

  CourseNana.COM

Additional Implementation Requirements: CourseNana.COM

·       Your user interface must provide clear instructions for the user and information about the data being presented. CourseNana.COM

·       Use of dynamic array is required. CourseNana.COM

·       Use of structs is required. CourseNana.COM

·       Your program must catch all errors (including different data types) and recover from them. CourseNana.COM

(Hint: all user inputs should be read/store as strings. That way, you only have to check for exact equality. CourseNana.COM

i.e., instead of checking if (user_input == 4), you can check if (user_input == “4”) instead) CourseNana.COM

·       You are not allowed to use libraries that are not introduced in class. CourseNana.COM

·       Your program should be properly decomposed into tasks and subtasks using functions, including main(). CourseNana.COM

To help you with this, use the following: CourseNana.COM

o   Make each function do one thing and one thing only. CourseNana.COM

o   No more than 15 lines inside the curly braces of any function, including main(). Whitespace, variable declarations, single curly braces, vertical spacing, comments, and function headers do not count. CourseNana.COM

o   Functions over 15 lines need justification in comments. CourseNana.COM

o   Do not put multiple statements into one line.    CourseNana.COM

·       No global variables allowed (those declared outside of many or any other function, global constants are allowed). CourseNana.COM

·       No goto function allowed. CourseNana.COM

·       You must not have any memory leaks or memory errors. CourseNana.COM

·       You program should not have any runtime error, e.g. segmentation fault CourseNana.COM

·       Make sure you follow the style guidelines, have a program header and function headers with appropriate comments, and be consistent. CourseNana.COM

  CourseNana.COM

  CourseNana.COM


CourseNana.COM

Compile and Submit your assignment CourseNana.COM

In order to submit your homework assignment, you must create a zip file that contains your .h, .cpp, and Makefile files. This tar file will be submitted to TEACH . In order to create the tar file, use the following command: CourseNana.COM

zip assign2.zip catalog.h catalog.cpp run_catalog.cpp makefile CourseNana.COM

Note that you are expected to modularize your code into a header file (.h), an implementation file (.cpp), and a driver file (.cpp). CourseNana.COM

You do not need to submit the txt files. The TA’s will have their own for grading. CourseNana.COM

Remember to sign up with a TA to demo your assignment. The deadline of demoing this assignment without penalties is 11/10/2023. CourseNana.COM

  CourseNana.COM

Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
Oregon State University代写,CS 162代写,Introduction to Computer Science II代写,C++代写,The Hooping Catalog代写,Oregon State University代编,CS 162代编,Introduction to Computer Science II代编,C++代编,The Hooping Catalog代编,Oregon State University代考,CS 162代考,Introduction to Computer Science II代考,C++代考,The Hooping Catalog代考,Oregon State Universityhelp,CS 162help,Introduction to Computer Science IIhelp,C++help,The Hooping Cataloghelp,Oregon State University作业代写,CS 162作业代写,Introduction to Computer Science II作业代写,C++作业代写,The Hooping Catalog作业代写,Oregon State University编程代写,CS 162编程代写,Introduction to Computer Science II编程代写,C++编程代写,The Hooping Catalog编程代写,Oregon State Universityprogramming help,CS 162programming help,Introduction to Computer Science IIprogramming help,C++programming help,The Hooping Catalogprogramming help,Oregon State Universityassignment help,CS 162assignment help,Introduction to Computer Science IIassignment help,C++assignment help,The Hooping Catalogassignment help,Oregon State Universitysolution,CS 162solution,Introduction to Computer Science IIsolution,C++solution,The Hooping Catalogsolution,