COM6102 Resit Project: A Portuguese wines browser
Your task is to build a browser of Portuguese “Vinho Verde” wine samples. This project will make substantial use of the material you have been taught in the course. In particular, you will employ the Java Collections Framework at the beginning, and Java Swing for the GUI-building (Swing contains components which make building a simple web browser relatively easy).
The assignment is divided into three parts, which are worth 35%, 35% and 30% respectively of your overall mark. Each part of the project builds on the core developed in the previous part. First, you will write code to read the details of Portuguese wine samples (PWs) from text file into a suitably designed collection of objects. You will produce some summary statistics as output. In part 2, you will develop a query language to produce more detailed searches of PW information. In the final part, you will link your query code to a graphical user interface which will produce a user-friendly display of PWs based on the results of queries as well as summary statistics for all wine samples in the provided datasets.
You may use any part of the standard Java API to solve the problem, but you may not use third-party software e.g. you cannot use the Sheffield package or GUI builders.
What to hand in & assessment
Once you have finished this project, you should submit via email to the lecturer the following:
Your code in a zip file, including all your java source (.src) and .class files.
A PDF document with the follow sections (maximum length of report is 5 pages):
a. A class diagram showing all the classes and any relationships between them (max 1 page).
b. A brief justification of the design of your classes (max 1 page).
c. A brief description and justification of your choice of collections framework objects used to store the
wine samples data (max 1⁄2 page).
d. A brief description and justification of your choice of collections framework objects with relation to
the ease and efficiency of processing the given queries (max 1⁄2 page).
e. A brief description and justification of your choices of Swing classes used to build your GUI. Please,
include snapshots of the different features supported by your program (max 2 pages). A text file listing the queries you have used to test your program.
Finally, in a 15-min session, you will also demonstrate your work and answer questions about your assignment to the lecturer. This meeting will be conveniently arranged with the lecturer via e-mail after submitting your assignment.
Submissions will be assessed against the following criteria:
• correct outputs (30%), evaluated on the basic test documents supplied, and more strenuous hidden tests. • sensible and efficient programming practices (40%), encompassing well designed algorithms and data
structures, sensible use of the Java API, and good use of exceptions. You should consider how well your program will handle large numbers of documents, in terms of speed of operation and memory usage. You should strive to make your code robust, such that it can behave sensibly even when there are errors in the input files.
• good object-oriented design, clear documentation and good coding style (30%). Remember that readability is of paramount importance. This means choosing good names for classes, variables and methods, taking care with line breaks, using documentation when required (but not excessively), using indentation (but not too much, 2 or 4 characters per indent is fine). As a last check before handing in, ask yourself whether your code is readable by someone marking it, and try viewing your source files with a different editor to ensure that your indentation will display correctly (n.b., set your editor to use spaces rather than tab characters).
Code that does not compile will be assigned a score of 0. Compiler warnings will also attract a penalty – these are symptomatic of problems in the code, which should be fixed before submission.
Note, this is an individual assessment. You are not allowed to work in groups and your code must be all your own work. You may not use other peoples’ code or ideas, e.g., taken from the Internet. Plagiarism or collusion will lead to a loss of marks and possible failure of the module.
Portuguese Wine Samples (PWs)
Assessing the quality of wines is critical to the wine industry in countries producing this good. In this project, you will build a browser that will allow wine producers to explore the quality of their wine based on the wine samples previously collected by them. Your browser will handle two types of Portuguese wine samples of the “Vinho Verde” variety: red and white. For each wine sample, there are objective tests (e.g. PH values) and subjective ones based on sensory data (median of at least 3 evaluations made by wine experts). Each expert graded the wine quality with a numerical value between 0 (worst) and 10 (best).
You can download the two original datasets for the red and white “Vinho Verde” varieties from the UCI Machine Learning Repository1 using the following two links:
– Red: http://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-red.csv
– White: http://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-white.csv These datasets were collected as part of a research project and the creators are acknowledged at the end of this handout.
Both files are text and use the Comma Separated Values file format (CSV). In this case, the first row provides the twelve categories listed below and the remaining rows list the numerical values for each of the wine samples in the datasets. You can use spreadsheet software to verify that your program is working as desired (e.g. Excel, Google Sheet, Numbers…).
Below you can find a brief description of the variables available for each wine sample (these are the twelve variables listed in the first row of the CSV file):
Objective physicochemical measurements:
1 – fixed acidity
2 – volatile acidity
3 – citric acid
4 – residual sugar
5 – chlorides
6 – free sulfur dioxide 7 – total sulfur dioxide 8 – density
9 – pH
10 – sulphates
11 – alcohol
Subjective wine quality assessment (based on sensory data):
12 – quality (score between 0 and 10)
You do not need to know much about these and other terms to do the project, but if you wish to find out more, look in Wikipedia or in the paper referenced in the acknowledgments for this assignment.
Part 1 Provide Summary Statistics
Your overall task is to produce, in an efficient manner, some summary statistics about the data. You will need to read all the data from the available files into a suitable set of Java classes. Develop a class called PWB which you will use to load the data files and ʻpopulateʼ the Portuguese wine sample objects. Focus first on reading the data from one of the files. Remember to use appropriate exception-handling to deal with any unexpected events. The main method of PWB should take 2 arguments: the names of the 2 data files (first the file containing details about the red wine samples, and second the file containing details about the white wine samples). Do not hard-code these into the program as you might need to demonstrate our code with different files (failure to do this will be associated to mark loss).
You should call your program via command line as follows:
PWB [filenameWithRedWineSamples.csv] [filenameWithWhiteWineSamples.csv]
1. Once you are convinced that your reading code is working, think about what structures will be needed to store all the objects in the files. Study the collections framework carefully.
2. Implement the structures as instance variables of PWB and complete the code which reads the objects from file.
At this point, you should have a program which loads all the information in the 2 files into useful structures within your program. You are now ready to produce some simple summary statistics and answers to simple queries.
If you have a good design, you will find that the code required to answer each query is quite small – a few lines at most. The queries you need to answer are:
Q1. How many wine samples are there?
Q2. How many red wine samples are there?
Q3. How many white wine samples are there?
Q4. Which objects were graded with the best quality?
Q5. Which objects were graded with the worst quality?
Q6. Which objects have the highest PH?
Q7. Which objects have the lowest PH?
You will need to think about how efficient your code is for answering these queries, and how this might impact on your design and choice of data structures.
Please, provide self-informative and easy-to-read outputs to these questions. Part 2 Querying Portuguese wine sample objects
Next, you will need to develop a simple query language for selecting Portuguese wine samples from the two loaded datasets. The queries will be lines of text of the form:
select red where quality > 6
select white or red where quality < 6 and quality > 4 and PH > 0.2
The first query should produce all red wine samples whose quality is greater than 6. The second should find white or red wine samples whose quality is between 4 and 6, with a PH above 0.2.
You should implement the following comparison operators: >, >=, =, !=, <=, <
In your design, try to make the main query-handling routines as independent as possible from the application. Think about how in the future you may wish to reuse them with other types of objects in applications unrelated to wines. To do that, you can follow this outline:
1. Design structures and classes to represent a query.
2. Write code to convert a text string such as the examples above into a query object.
3. Write methods to carry out the matching process. The result of applying a query to a collection of Portuguese wine samples should be another collection of Portuguese wine samples which is the subset of the original objects which satisfy the query.
4. Test your code using self-made queries. You should output the number of elements which match each query. You should submit the queries you have built to test your program.
5. Ensure that your code produces meaningful messages when it encounters problems with the queries. For instance, if the query refers to an instance variable or comparison operator which does not exist, a suitable message should be provided. Examples of malformed queries are these (errors are highlighted in bold): select wine where PHRR > 60
select reds where qua – 3
Part 3 Building a GUI
Your task is to develop a graphical user interface (GUI) for selecting and viewing Portuguese wine samples. You should use Swing and you should not use visual design tools to create the interface.
The interface should contain the following elements:
– a region where some or all the Portuguese wine samples can be displayed,
– a region where users can easily formulate a query of the kind used in part 2, which is then applied to the
data and results in a display of the Portuguese wine samples which match the query,
– any other regions you think necessary to make the interface easy to use and informative.
There are several marks (up to 20% under functionality) which can be allocated to design flair. Note that flair is not the same as flash! Any interface which is easy to use and yet manages to provide the user with access to all the information in the various data files in a non-overwhelming fashion will be rewarded.
You should choose the most appropriate mechanism for inputting the information needed in the queries. It would be wrong, for instance, to simply input queries in a text box. Think about other programs you have used in which similar forms of queries are used.
You should NOT use a GUI builder, but instead craft the UI by hand. Although GUI builders can be used to put together a UI quickly, the result is typically not very robust (e.g., resizing the window, custom font sizes) and the code is often unreadable. Also, if you’ve used a GUI builder then it’s not clear to me if you understand the code. By all means use UI builders to prototype your interface, but you should write the UI yourself.
If you have any questions about the assignment, you can email the lecturer.
Acknowledgment to the research team that created this dataset:
P. Cortez, A. Cerdeira, F. Almeida, T. Matos and J. Reis. Modeling wine preferences by data mining from physicochemical properties. In Decision Support Systems, Elsevier, 47(4):547-553. ISSN: 0167-9236.
本网站支持 Alipay WeChatPay PayPal等支付方式
E-mail: firstname.lastname@example.org 微信号:vipnxx