塔斯马尼亚大学KIT107课业解析

  • May 15, 2020

题意:  玩具公司请你设计一款app,用于管理公司收集的弹珠、分析数据和阐释它们多样的分布。你需要显示每个成员的弹珠数、每种大小的弹珠数、每种样式的弹珠数等。
俱乐部一共有7名成员,分别是Scott Malcolm Tony Kevin
Julia John和Paul。游戏只统计这七名成员的弹珠信息。每名成员的弹珠分别存储在计算机化的集合中,方便使用。解析: 
  背景:  每颗弹珠存储以下信息:直径以毫米作为单位(double型)、花纹(enumeration类型)、材料(enumeration类型)、新旧(bool型)。弹珠集合按照直径的升序排列存储信息。
你将收到一个存储俱乐部收藏的弹珠基本信息的txt文件。  任务:  回答以下问题:  a.对于七名成员的弹珠集合,你将使用哪种底层数据结构(数组还是链表)?说明原因。  b.对于七名成员的弹珠集合,你将使用哪种抽象数据类型(二叉树、一般树、数组、栈、优先队列、双端队列、集合、列表等)?说明原因。  c.对于俱乐部的弹珠集合,你将使用哪种底层数据结构(数组还是链表)?说明原因。  d.对于俱乐部的弹珠集合,你将使用哪种抽象数据类型(二叉树、一般树、数组、栈、优先队列、双端队列、集合、列表等)?说明原因。  完成下列函数:    1、get_member()——查找俱乐部成员——以一名成员名字为输入,在MEMBERS数组中查找并返回索引值(数组不存在该名字返回 -1)—— 调用strcmp()函数  2、add_existing()——加入一颗弹珠到成员弹珠集合——以一名成员的非空弹珠集合地址和一颗弹珠为输入,按直径升序把该弹珠加入该成员的弹珠集合中 —— 利用指针插入新结点  3、add_marble()——加入一颗弹珠到俱乐部弹珠集合——以一名成员的名字和弹珠的一颗弹珠为输入,如果该成员没有这个弹珠就把成员名字和弹珠存入club集合中,否则调用add_existing()函数  4、process_category()——统计与分类——以一名成员的弹珠集合为输入,接受以下4个参数分别对应不同的分类操作,返回       ‘t’——计算弹珠集合的总数       ‘m’——计算不同材质的弹珠数量——材质有plastic,wooden,glass之别       ‘c’——计算不同花纹的弹珠数量——花纹有plain,swirled,cats-eye之别       ‘a’——计算新老弹珠的数量——弹珠有old,new之别  5、show_graph()——可视化展现统计结果——以上述4个参数为输入,输出一串字符表示数量大小,分别统计所有类型并输出最多的成员名字涉及知识点:抽象数据类型,数组,文件读取更多可加微信讨论微信号:ITCSdaixie

KIT107 Programming 2019Assignment 2Due DateThe assignment is due at 3PM Wednesday September 18th 2019BackgroundMarbles! Large ones, medium-sized ones, small ones. Cats-eye ones, plain ones,swirly ones. Glass ones, wooden ones, plastic ones. Old ones, new ones. Marbles!A Toy Company has asked you to develop an app to manage a club’s collection ofmarbles, to analyse the data and illustrate various distributions. You will need toshow the number of marbles per member, the number per size and style, et cetera.There are seven members in the Club: Scott, Malcolm, Tony, Kevin, Julia, John, andPaul. Only marbles from these seven members will be stored. Marbles belonging toothers should be ignored. All marbles belonging to the same member should bestored in the computerised collection together for ease of access.Each marble should have its diameter in millimetres (a double), content (anenumeration), material (an enumeration), and age (a bool) stored. The collection ofmarbles for each member should be stored in increasing order of diameter (smallestfirst).2/9A text file exists with the basic data of the marbles found at the Clubhouse. I willgive you code to read this into your program. You will need to illustrate (using a barchart and/or some print outs) various information.a Which underlying data structure (array or linked-list) will you use as a basis tomodel the collection of marbles for each of the seven members? In two–threesentences, justify your answer.b Which kind of abstract data type (binary tree, general tree, array, stack, priorityqueue, double-ended queue, set, list, etc.) would you use to model the collectionof marbles for each of the members? In two–three sentences, justify youranswer by indicating the functionality required.c Which underlying data structure (array or linked-list) will you use as a basis tomodel the collection of members? In two–three sentences, justify your answer.d Which kind of abstract data type (binary tree, general tree, array, stack, priorityqueue, double-ended queue, set, list, etc.) would you use to model the collectionof members? In two–three sentences, justify your answer by indicating thefunctionality required.The types required to implement this include the following:typedef struct {char *name;collection marbles;} member;typedef member members;#define NUM_MEMBERS 7const char *MEMBERS[] = { “Scott”, “Malcolm”, “Tony”,”Kevin”, “Julia”, “John”, “Paul” };members club;In other words, you must create a struct (called member in the above example)which combines the member name with your answer to (a) above to represent thecollection of marbles for that particular member, and then use that as a basis foranother type (used to create a variable called club in the above example) which usesyour answer to (c) above to create a collection of members.A marble is defined as follows:struct marble_int {double diameter;content look;material made_of;bool new;};3/9typedef struct marble_int *marble;and you may assume the existence of those types and the following types andfunctions:typedef enum {plain, swirled, cats_eye} content;typedef enum {glass, wooden, plastic} material;void init_marble(marble *e, double d, content c,material m, bool n);double get_diameter(marble e);material get_look(marble e);content get_material(marble e);bool get_age(marble e);void set_diameter(marble e, double d);void set_look(marble e, content c);void set_material(marble e, material m);void set_age(marble e, bool n);char *to_string(marble e);A Visual Studio project is available on MyLO for you to download and use as astarting point. This comprises the following files:• marble.h and marble.c — the Marble ADT as specified above. Thesefiles are complete;• assig_two219.c — the file which contains the main() function andother functions which implement the required task (including reading marblesfrom the text file).e You must complete assig_two219.cStart by adding the collection and members types from above. You mayadd other types, constants and variables as necessary.Then, complete the following functions:• get_member() — which takes a member name, locates it in theMEMBERS array and returns its index (or –1 if it is not present);• add_existing() — which takes the address of a non-emptycollection of marbles for a particular member and an marble to add tothat member’s collection and which adds the marble to the collection inincreasing order of diameter;• add_marble() — which takes the name of a member and a marbleand which either stores the name and marble in club if there are nonefor that member yet, or which calls add_existing() to do so if thereare already marbles for that member;• process_category() — which takes a collection of marbles for aparticular member, a letter indicating which category should beprocessed, and an ‘int’ indicating which value in the category theprocessing should occur for. Possible letters, values and actions are:4/9o ‘t’ — calculate the total number of marbles in the collection;o ‘m’ — calculate the number of marbles of that particularmaterial (plastic, wooden, or glass);o ‘c’ — calculate the number of marbles of that particular contentvalue (plain, swirled, or cats-eye); ando ‘a’ — calculate the number of marbles of that particular agevalue (old or new).The answer (an int) should be returned.• show_graph() — which takes a letter (see above), a string descriptionof the output to be displayed (see sample output), and a value for thecategory (see above) or –1 if the category is total — and which displaysthe histogram of, and totals (which can be obtained usingprocess_category() for each member); and• main() — which should initialize club, call read_in_data(), andcall show_graph().If your answer to (a) or (c) above is a linked-list then you will also need to writenode.h and node.c and add them to the project.The project also contains the data file. This is just a text file which can be opened andread with most applications. It contains details of marbles found in the Clubhouse,but sometimes there are marbles which were left there by previous members.Program specificationFirst you must obtain the marbles from a text file. The data must be stored inappropriate collections. At the top level there should be 7 members and for each thereshould be a collection of marbles (stored in ascending order of diameter).As a marble is read from the file, the details should be checked for validity. If invalid— i.e. not belonging to a current member — it should be counted, but not included inthe collection. If valid, its data should be stored in its members part of the collection.Once the data have been read in and stored in the collections, output should beprovided as specified in the preceding section.A histogram illustrating the results per member should be displayed with one asteriskprinted for every 25 marbles (other than for diameter — see sample output below).Each histogram should state the count of ‘invalid’ marbles beneath it.The output of your program should look something like the following (with the boldadded in this document for emphasis only):5/9Marbles — total number ofScott | ************************************************************************ 1822Malcolm | ************************************************************************** 1858Tony | **************************************************************************** 1911Kevin | ************************************************************************** 1867Julia | ************************************************************************** 1867John | ************************************************************************* 1846Paul | ***************************************************************************** 1942Invalid marbles: 1887And the most common member for total number of marbles is……Paul!Marbles — glassScott | ************************ 624Malcolm | ************************* 634Tony | ************************ 613Kevin | ************************* 643Julia | *********************** 594John | *********************** 599Paul | ************************* 648Invalid marbles: 1887And the most common member for glass marbles is……Paul!Marbles — woodenScott | *********************** 598Malcolm | ************************ 622Tony | ************************* 643Kevin | *********************** 594Julia | ************************** 664John | ************************* 638Paul | *************************** 681Invalid marbles: 1887And the most common member for wooden marbles is……Paul!Marbles — plasticScott | ************************ 600Malcolm | ************************ 602Tony | ************************** 655Kevin | ************************* 630Julia | ************************ 609John | ************************ 609Paul | ************************ 613Invalid marbles: 1887And the most common member for plastic marbles is……Tony!Marbles — solid colourScott | *********************** 598Malcolm | ************************* 628Tony | ************************ 623Kevin | ************************* 631Julia | *********************** 581John | *********************** 587Paul | ************************** 664Invalid marbles: 1887And the most common member for solid colour marbles is……Paul!6/9Marbles — swirled colourScott | *********************** 575Malcolm | ************************ 619Tony | ************************ 614Kevin | ************************ 617Julia | ************************* 642John | ************************ 620Paul | ********************** 570Invalid marbles: 1887And the most common member for swirled colour marbles is……Julia!Marbles — cats_eye patternScott | ************************* 649Malcolm | ************************ 611Tony | ************************** 674Kevin | ************************ 619Julia | ************************* 644John | ************************* 639Paul | **************************** 708Invalid marbles: 1887And the most common member for cats_eye pattern marbles is……Paul!Marbles — oldScott | ************************************ 911Malcolm | ************************************** 973Tony | ************************************* 944Kevin | ************************************** 950Julia | ************************************ 914John | ************************************* 930Paul | **************************************** 1010Invalid marbles: 1887And the most common member for old marbles is……Paul!Marbles — newScott | ************************************ 911Malcolm | *********************************** 885Tony | ************************************** 967Kevin | ************************************ 917Julia | ************************************** 953John | ************************************ 916Paul | ************************************* 932Invalid marbles: 1887And the most common member for new marbles is……Tony!Program StyleThe program you write for this assignment must be contained in five files as follows:• marble.h and marble.c for managing a marble;• node.h and node.c for nodes of linked lists (if appropriate);• assig_two219.c for the main algorithm which controls the reading of thedata, the management of the collections, the calculation of the results, and the7/9display of the histogram. No function should be longer than about half ascreen-full or so of code.Your program should follow the following coding conventions:• const variable identifiers should be used as much as possible, should bewritten all in upper case and should be declared before all other variables;• #defined symbols should only be used for constant values if const isinappropriate, for example the size of an array.• global variables should be used sparingly with parameter lists used to passinformation in and out of functions.• local variables should only be defined at the beginning of functions and theiridentifiers 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 andthe 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 dateo Each variable declaration should be commentedo There should be a comment identifying groups of statements that dovarious parts of the tasko Comments should describe the strategy of the code and should notsimply translate the C into EnglishWhat and how to submitWhat to submitYou must make both a paper and an electronic submission.Paper submission• A paper cover page (blanks can be collected from the Information andCommunications Technology Discipline Help Desk and downloaded fromMyLO).• Written answers to parts (a)–(d) above.• A landscape oriented print-out of assign_two219.c and any otherprogram files you have added to the solution. Your assignment will not be fullymarked unless these are present.8/9Electronic submission• You should submit the entire Visual Studio project folder compressed as a ZIPfile.How to submitPaper submission• Firmly staple together all of the required documents (with the signed coverpage on top) and place them in the appropriate submissions box near the ICTHelp Desk.Electronic submission• You should ZIP the Visual Studio project folder and then submit it to the“Assignment 2” assignment drop-box on KIT107’s MyLO site.Marking scheme33622223141121124444444449/9Plagiarism and Cheating:Practical assignments are used in the ICT discipline for students to both reinforce anddemonstrate their understanding of material which has been presented in class. Theyhave a role both for assessment and for learning. It is a requirement that work youhand in for assessment is substantially your own.Working with othersOne effective way to grasp principles and concepts is to discuss the issues with yourpeers and/or friends. You are encouraged to do this. We also encourage you to discussaspects of practical assignments with others. However, once you have clarified theprinciples, you must express them in writing or electronically entirely by yourself. Inother words you must develop the algorithm to solve the problem and write theprogram which implements this algorithm alone and with the help of no one else(other than staff). You can discuss the problem with other students, but not how tosolve it.Cheating• Cheating occurs if you claim work as your own when it is substantially thework of someone else.• Cheating is an offence under the Ordinance of Student Discipline within theUniversity. Furthermore, the ICT profession has ethical standards in whichcheating has no place.• Cheating involves two or more parties.o If you allow written work, computer listings, or electronic version ofyour code to be borrowed or copied by another student you are anequal partner in the act of cheating.o You should be careful to ensure that your work is not left in a situationwhere it may be stolen by others.• Where there is a reasonable cause to believe that a case of cheating hasoccurred, this will be brought to the attention of the unit lecturer. If thelecturer considers that there is evidence of cheating, then no marks will begiven to any of the students involved. The case will be referred to the Head ofthe Discipline of ICT for consideration of further action.Julian Dermoudy, August 27th 2019.Version 1: 19/8/2019Version 2: typographical corrections  

LATEST POSTS
MOST POPULAR

ezAce多年来为广大留学生提供定制写作、留学文书定制、语法润色以及网课代修等服务,超过200位指导老师为您提供24小时不间断地服务。

Close Bitnami banner
Bitnami