Skip to main content
留学咨询

辅导案例-CMP-4008Y

By May 15, 2020No Comments

School of Comput_ing Sciences Module: CMP-4008Y Programming 1Assignment: Coursework 1 – Electronic Component Inventory Program Set by: Dr Gavin Cawley ([email protected])Date set: 1st November 2019Value: 20% Date due: 5th December 2019 3pmReturned by: 13th January 2020Submission: evision Learning outcomes The aim of this assignment is for the student to gain experience in the design and implementa-t_ion of a relat_ively small program using an object oriented approach. This will further reinforcethe student’s grasp of fundamental concepts such as classes, objects, instance variables andmethods, but will also introduce the use of mult_iple classes, each of which definine a differenttype of object. During the assignment, the student will also begin to gain object-oriented de-sign skills by deciding how the state and behaviors of the objects should be implemented andhow the objects should interact. On successful complet_ion of this exercise, the student will have reinforced a basic under-standing of the concepts of classes and objects, will be familiar with the basic syntax of Javaprogramming constructs used to implement classes, instance variables and methods and willbe able to select the instance variables andmethods required to represent the state and behav-iors of simple types of real-world objects. The student will have gained familiarity with someof the classes in the Java standard libraries used for file based I/O and collect_ions. The studentwill also have an improved ability to use the ideas of cohesion and coupling to guide the designof programs comprised of more than a single class definit_ion. Specificat_ion Overview Chartlins is a company that specialises in providing electronic components for hobbyists tobuild simple electronic circuits of their own design, or from a kit of parts. They have hired youto write a system to manage their inventory of components etc. The program must be writ_tenin the Java progamming language and demonstrate the use of classes and object-orienteddesign to write modular, maintainable programs. The file inventory.txt provides details ofthe company’s inventory of electronic components (resistors, capacitors, diodes, transistorsand integrated circuits). For each stock item, the file provides the component type, the stockcode, the number of items in stock and the unit price in pence. The remainder of the recordprovides some addit_ional informat_ion: 1 • Resistors — the resistance in Ohms (see en.wikipedia.org/wiki/RKM_code for de-tails). • Capacitors — the capacitance in Farads, encoded in a manner similar to resistance. • Diodes — no addit_ional informat_ion. • Transistors — an indicat_ion whether they are NPN, PNP or FET devices. • Integrated Circuits (ICs) — a brief descript_ion. The programmust read the data in this file intomemory, stored in an appropriate set of objects,and print answers to the following queries on the console: • Print a list of the inventory, sorted in order of increasing price. • What is the component with the largest number of components in stock? • How many NPN transistors does Chartlins have in stock? • What is the total resistance of all of the resistors in stock? • How many stock items have unit prices above 10p? The program should consist of three files, which define the basis of the marking scheme: • StockItem.java, which should define a class that records the informat_ion about a stockitem. • Inventory.javawhich should define a class represent_ing the inventory of the company,using some appropriate data structure or container. The class should have methods thatassist in answering the same queries as before (the methods should be generic so theycould potent_ially be used to answer similar queries, rather than specifically those givenin the specificat_ion). • StockProgram.java This file contains the main part of the program that loads and pro-cesses the inventory data, and provides answers to the five queries. Note that inventory.txt may change before the due date for the assignment, and the an-swers to the queries must be based on the final version of that file. Relat_ionship to format_ive assessment This assignment builds on the skills gained from the laboratory exercises for cmp-4008Y thathave already been completed, for which format_ive feedback can be obtained from the teachingassistants during your scheduled laboratory session. Deliverables Your solut_ion must be format_ted using the PASS program, available on all laboratory machines,to produce a PDF file containing the source code of the program, the compilermessages (if any)and the output of the program. The PDF must then be submit_ted via evision. Your solut_ion willonly be marked if it has been submit_ted via evision. 2 The PASS program is not able to provide input to your program via the keyboard, so pro-grams with a menu system, or which expect user input of some kind are not compat_ible withPASS. Design your program to operate correctly without user input from the keyboard. We strongly recommend that the student also uploads this .pdf file (or alternat_ively a .zipfile containing the source code for your program) to BlackBoard. There may be some issuesthat are not easily resolved using only the printed code list_ing, and the markers may wish tocompile and run the program for themselves. This may affect the mark awarded either posi-t_ively (by reassuring the marker that the code executes correctly and efficiently) or negat_ively(for instance because the code does not execute correctly or is inefficient). If you develop your solut_ion on a computer other than the laboratory machines, make surethat you leave t_ime to test it properly with PASS, in case of any unforseen portability issues. Ifyour programworks correctly under InteliJ on the labmachines, but does not operate correctlyusing PASS, then it is likely that the data file (inventory.txt) you are using has become cor-rupted in some way. PASS downloads a fresh version of the file to test your submission, so thisis perhaps the most likely explanat_ion. Resources • https://stackoverflow.com/ – An excellent site for finding informat_ion about specificissues relat_ing to various programming languages, including Java. It is important howevernot to become too reliant on sites such as StackOverflow, which are great for details,but don’t give the “big picture”, so it is difficult to get a good understanding of program-ming in this way. Note that if you re-use or modify code found on-line, then you mustprovide a comment giving the URL and a brief explanat_ion of what modificat_ions havebeen made. Re-using code found on-line without proper at_tribut_ion would const_ituteplagiarism. • https://docs.oracle.com/javase/tutorial/ – A set of tutorials, provided by Ora-cle, who now develop the Java programming language. • https://docs.oracle.com/javase/8/docs/api/ – JavaApplicat_ionProgramming In-terface (API) documents. Very useful for finding out what methods a class from the Javastandard libraries provide. Plagiarism and collusion: Stackoverflow and other similar forums (such as the module dis-cussion board) are valuable resources for learning and complet_ing format_ivework. However,forassessed work such as this assignment, you may not post quest_ions relat_ing to coursework so-lut_ions in such forums. Using code from other sources/writ_ten by others without acknowledge-ment is plagiarism, which is not allowed (General Regulat_ion 18) Marking Scheme Marks will be awarded according to the proport_ion of specificat_ions successfully implemented,programming style (indentat_ion, good choice of ident_ifiers, comment_ing etc.), and appropri-ate use of programming constructs. It is not sufficient that the program generates the correctoutput, professional programmers are required to produce maintainable code that is easy tounderstand, easy to debug when (rather than if) bug reports are received and easy to extend.The code needs to be modular, where each module has a well-defined interface to the rest ofthe program. The funct_ion of modules should be made as generic as possible, so that it notonly solv
es the problem specified today, but can easily be modified or extended to implement 3 future requirements without undue cost. The code should also be reasonable efficient. Marksmay also be awarded for correct use of more advanced programming constructs not coveredin the lectures. The marking scheme is as follows (out of 100 marks): • StockItem.java – 40 marks. • Inventory.java – 25 marks. • StockProgram.java – 10 marks. • The remaining 25 marks are awarded for the answers to the five inventory quest_ionslisted above (five marks each). 4

admin

Author admin

More posts by admin