Aim The aim of this assignment is to add a class to the project that you developed for the first part of the coursework to make a graphical user interface (GUI) for a system that stores details of...

1 answer below »


Aim



The aim of this assignment is to add a class to the project that you developed for the first part of the coursework to make a graphical user interface (GUI) for a system that stores details of gadgets in a shop. The class will contain a main method and will be tested using the command prompt. You will also need to write a report about your program. You are advised to study the learning aid on reflective practice, which is linked from the module WebLearn homepage, and the learning aids entitled “Using the Command Prompt” and “Examples of screenshots for Coursework 2” which are included in the learning and teaching materials. Your report should be no more than 1200 words in length (excluding the table of contents, class diagram, pseudocode and code listing).





Deliverables



Create a new class within the project called GadgetShop. When you are ready to submit your solution, upload your GadgetShop.java file, together with the Gadget.java, Mobile.java and MP3.java files from the first part of the coursework (not any other files from the project) to WebLearn together with your report in Microsoft Word and, when you are absolutely sure that you have uploaded the correct files, press the submit button. (You will not need to make any changes to the Gadget, Mobile or MP3 classes as long as they work correctly, but ask your tutor if you need help completing those classes to the specification of the first part of the coursework.)




Program



An example GUI is shown below:











Your GUI should contain the same components but you are free to use a different layout if you feel that it improves the aesthetics, ease of use etc. The GadgetShop class should store an array list (not an array) of type Gadget to hold the gadgets.





Text Field Input Methods



For each text field, write a method to read its contents and return the value. For the model, size and phone number, the value should simply be returned as a string but, for each of the other text fields, the input value should be converted into its correct numerical data type and then that value should be returned.



There should be text fields for entering:



· The model


· The price


· The weight


· The size


· The initial credit (when adding a mobile phone)


· The initial available memory (when adding an MP3 player)


· The phone number (when making a mobile phone call)


· The duration (when making a mobile phone call)


· The download size (when downloading music to the MP3 player)


· The display number, which is the same as the index of the gadget in the array list




The input method for the display number is different from the input methods for the other text fields. The method first initialises the display number to -1. If the input from the user via the GUI is valid, the display number will be changed to a value that corresponds to a gadget in the array list. The input from the display number text field must therefore be tested using a try/catch statement to ensure that the gadget number entered is an integer and, if it is, that it is in the correct range. If the value entered is an integer but is not in the correct range, a suitable error message is displayed using a message dialog box. If the display number entered is not an integer then an alternative error message is displayed using a message dialog box. The method will therefore either return –1 or a value that corresponds to a gadget in the array list, depending on whether or not there was an error in the input. Any method that gets the display number should check its value and only use it if its value is not equal to –1.




Buttons



The GUI should have the following buttons:




1)

Add Mobile



The model, price, weight, size and credit are input via the GUI. When this button is pressed, the methods to get the model, price, weight, size and credit are called, and these values are used to create a new object of type Mobile, which is added to the array list of gadgets.




2)

Add MP3



The model, price, weight, size and memory are input via the GUI. When this button is pressed, the methods to get the model, price, weight, size and memory are called, and these values are used to create a new object of type MP3, which is added to the array list of gadgets.




3)

Clear




When this button is pressed, the text is cleared from each of the ten text fields.




4)

Display All



When this button is pressed, the display number is printed and the method to display the details of the gadget is called, for each gadget in the array list.




5)

Make A Call



The display number, phone number and duration are input via the GUI. When this button is pressed, the method to get the display number is called and its value is checked. If it is not equal to –1:



· The display number is used to get the gadget from the array list and cast it to Mobile.


· The method to make a call in the Mobile class is called with the phone number and duration entered.




6)

Download Music



The display number and download size are input via the GUI. When this button is pressed, the method to get the display number is called and its value is checked. If it is not equal to –1:




· The display number is used to get the gadget from the array list and cast it to MP3.


· The method to download music in the MP3 class is called with the download size entered.




Marks



Marks will be awarded as follows:



1) GUI


2) The actionPerformed method


3) The main method


4) Functionality of buttons


5) Reading input


6) Use of try/catch, checking input and displaying appropriate message dialogs


7) Program style (see http://www.bluej.org/objects-first/styleguide.html)






Report



The report should contain:




A class diagram of the GadgetShop class only, showing the name of the class, the data types and names of the fields, and the return types and signatures of all of the methods.


Pseudocode for the following button-handling methods:




· Getting the display number from the GUI


· Adding a mobile


· Adding an MP3


· Displaying all gadgets in the array list


· Making a call


· Downloading music




A short description of each of the 6 methods above



You should give evidence (through appropriate screenshots) of the following testing that you carried out on your program:




Test 1: Adding a mobile to the array list


Test 2: Adding an MP3 player to the array list


Test 3: Displaying the details of all of the gadgets in the array list


Test 4: Making a call


Test 5: Downloading music


Test 6: Test that the program can be compiled and run using the command prompt, including a screenshot similar to Figure 1 in the command prompt learning aid.


Test 7: Test that appropriate dialog boxes appear when unsuitable values are entered for the display number.


(Include a screenshot of the dialog box, together with a corresponding screenshot of the GUI, showing the values that were entered.)





The report should contain a section on error detection and error correction where you give examples and evidence of three errors encountered in your implementation. The errors (syntax and/or runtime) should be distinctive and not of the same type.



The report should contain a conclusion, where you evaluate your work, reflecting on what you learnt from assignment. You are advised to study the learning aid on reflective practice, which is linked from the module in WebLearn.



The report should include a title page, a table of contents (with page numbers), and a listing of the code (in an appendix). Marks will also be awarded for the quality of writing and the presentation of the report.


Answered Same DayMar 31, 2021

Answer To: Aim The aim of this assignment is to add a class to the project that you developed for the first...

Mohd answered on Apr 18 2021
130 Votes
GadgetShop/doc/allclasses-frame.html
All Classes
        Gadget
GadgetShop/doc/allclasses-noframe.html
All Classes
        Gadget
GadgetShop/doc/constant-values.html
JavaScript is disabled on your browser.
Constant Field Values
Contents
GadgetShop/doc/Gadget.html
JavaScript is disabled on your browser.
Class Gadget
        java.lang.Object
        
        Gadget
        
public class Gadget
extends java.lang.Object
        
        
Constructor Summary
Constructors         Constructor and Description
        Gadget(java.lang.String model,
java.lang.String size,
double price,
int weight) 
        
Method Summary
All Methods Instance Methods Concrete Methods         Modifier and Type        Method and Description
        java.lang.String        getModel() 
        double        getPrice() 
        java.lang.String        getSize() 
        int        getWeight() 
        void        printGadget() 
        
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
        
        
Constructor Detail
        
Gadget
public Gadget(java.lang.String model,
java.lang.String size,
double price,
int weight)
        
Method Detail
        
getModel
public java.lang.String getModel()
        
getPrice
public double getPrice()
        
getSize
public java.lang.String getSize()
        
getWeight
public int getWeight()
        
printGadget
public void printGadget()
GadgetShop/doc/index.html
GadgetShop/doc/logfile.txt
Class documentation
<---- javadoc command: ---->
C:\Program Files (x86)\BlueJ\jdk\bin\javadoc.exe
-author
-version
-nodeprecated
-package
-Xdoclint:none
-noindex
-notree
-nohelp
-nonavbar
-source
1.8
-classpath
C:\Program Files (x86)\BlueJ\lib\blu
ejcore.jar;C:\Program Files (x86)\BlueJ\lib\junit-4.11.jar;C:\Program Files (x86)\BlueJ\lib\hamcrest-core-1.3.jar;C:\Program Files (x86)\BlueJ\lib\lang-stride.jar;C:\Program Files (x86)\BlueJ\lib\userlib\pi4j-core.jar;C:\Program Files (x86)\BlueJ\lib\userlib\pi4j-device.jar;C:\Program Files (x86)\BlueJ\lib\userlib\pi4j-gpio-extension.jar;C:\Program Files (x86)\BlueJ\lib\userlib\pi4j-service.jar;C:\Users\Mohd Lucky\Documents\blueJ\GadgetShop
-d
C:\Users\Mohd Lucky\Documents\blueJ\GadgetShop\doc
-encoding
UTF-8
-charset
UTF-8
C:\Users\Mohd Lucky\Documents\blueJ\GadgetShop\Gadget.java
<---- end of javadoc command ---->
Loading source file C:\Users\Mohd Lucky\Documents\blueJ\GadgetShop\Gadget.java...
Constructing Javadoc information...
Standard Doclet version 1.8.0_144
Building tree for all the packages and classes...
Generating C:\Users\Mohd Lucky\Documents\blueJ\GadgetShop\doc\Gadget.html...
Generating C:\Users\Mohd Lucky\Documents\blueJ\GadgetShop\doc\package-frame.html...
Generating C:\Users\Mohd Lucky\Documents\blueJ\GadgetShop\doc\package-summary.html...
Generating C:\Users\Mohd Lucky\Documents\blueJ\GadgetShop\doc\constant-values.html...
Building index for all the packages and classes...
Building index for all classes...
Generating C:\Users\Mohd Lucky\Documents\blueJ\GadgetShop\doc\allclasses-frame.html...
Generating C:\Users\Mohd Lucky\Documents\blueJ\GadgetShop\doc\allclasses-noframe.html...
Generating C:\Users\Mohd Lucky\Documents\blueJ\GadgetShop\doc\index.html...
GadgetShop/doc/package-frame.html

Classes
        Gadget
GadgetShop/doc/package-list
GadgetShop/doc/package-summary.html
JavaScript is disabled on your browser.
Package 
        
Class Summary         Class        Description
        Gadget         
GadgetShop/doc/script.js
function show(type)
{
count = 0;
for (var key in methods) {
var row = document.getElementById(key);
if ((methods[key] & type) != 0) {
row.style.display = '';
row.className = (count++ % 2) ? rowColor : altColor;
}
else
row.style.display = 'none';
}
updateTabs(type);
}
function updateTabs(type)
{
for (var value in tabs) {
var sNode = document.getElementById(tabs[value][0]);
var spanNode = sNode.firstChild;
if (value == type) {
sNode.className = activeTableTab;
spanNode.innerHTML = tabs[value][1];
}
else {
sNode.className = tableTab;
spanNode.innerHTML = "" + tabs[value][1] + "";
}
}
}
GadgetShop/doc/stylesheet.css
/* Javadoc style sheet */
/*
Overall document style
*/
@import url('resources/fonts/dejavu.css');
body {
background-color:#ffffff;
color:#353833;
font-family:'DejaVu Sans', Arial, Helvetica, sans-serif;
font-size:14px;
margin:0;
}
a:link, a:visited {
text-decoration:none;
color:#4A6782;
}
a:hover, a:focus {
text-decoration:none;
color:#bb7a2a;
}
a:active {
text-decoration:none;
color:#4A6782;
}
a[name] {
color:#353833;
}
a[name]:hover {
text-decoration:none;
color:#353833;
}
pre {
font-family:'DejaVu Sans Mono', monospace;
font-size:14px;
}
h1 {
font-size:20px;
}
h2 {
font-size:18px;
}
h3 {
font-size:16px;
font-style:italic;
}
h4 {
font-size:13px;
}
h5 {
font-size:12px;
}
h6 {
font-size:11px;
}
ul {
list-style-type:disc;
}
code, tt {
font-family:'DejaVu Sans Mono', monospace;
font-size:14px;
padding-top:4px;
margin-top:8px;
line-height:1.4em;
}
dt code {
font-family:'DejaVu Sans Mono', monospace;
font-size:14px;
padding-top:4px;
}
table tr td dt code {
font-family:'DejaVu Sans Mono', monospace;
font-size:14px;
vertical-align:top;
padding-top:4px;
}
sup {
font-size:8px;
}
/*
Document title and Copyright styles
*/
.clear {
clear:both;
height:0px;
overflow:hidden;
}
.aboutLanguage {
float:right;
padding:0px 21px;
font-size:11px;
z-index:200;
margin-top:-9px;
}
.legalCopy {
margin-left:.5em;
}
.bar a, .bar a:link, .bar a:visited, .bar a:active {
color:#FFFFFF;
text-decoration:none;
}
.bar a:hover, .bar a:focus {
color:#bb7a2a;
}
.tab {
background-color:#0066FF;
color:#ffffff;
padding:8px;
width:5em;
font-weight:bold;
}
/*
Navigation bar styles
*/
.bar {
background-color:#4D7A97;
color:#FFFFFF;
padding:.8em .5em .4em .8em;
height:auto;/*height:1.8em;*/
font-size:11px;
margin:0;
}
.topNav {
background-color:#4D7A97;
color:#FFFFFF;
float:left;
padding:0;
width:100%;
clear:right;
height:2.8em;
padding-top:10px;
overflow:hidden;
font-size:12px;
}
.bottomNav {
margin-top:10px;
background-color:#4D7A97;
color:#FFFFFF;
float:left;
padding:0;
width:100%;
clear:right;
height:2.8em;
padding-top:10px;
overflow:hidden;
font-size:12px;
}
.subNav {
background-color:#dee3e9;
float:left;
width:100%;
overflow:hidden;
font-size:12px;
}
.subNav div {
clear:left;
float:left;
padding:0 0 5px 6px;
text-transform:uppercase;
}
ul.navList, ul.subNavList {
float:left;
margin:0 25px 0 0;
padding:0;
}
ul.navList li{
list-style:none;
float:left;
padding: 5px 6px;
text-transform:uppercase;
}
ul.subNavList li{
list-style:none;
float:left;
}
.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited {
color:#FFFFFF;
text-decoration:none;
text-transform:uppercase;
}
.topNav a:hover, .bottomNav a:hover {
text-decoration:none;
color:#bb7a2a;
text-transform:uppercase;
}
.navBarCell1Rev {
background-color:#F8981D;
color:#253441;
margin: auto 5px;
}
.skipNav {
position:absolute;
top:auto;
left:-9999px;
overflow:hidden;
}
/*
Page header and footer styles
*/
.header, .footer {
clear:both;
margin:0 20px;
padding:5px 0 0 0;
}
.indexHeader {
margin:10px;
position:relative;
}
.indexHeader span{
margin-right:15px;
}
.indexHeader h1 {
font-size:13px;
}
.title {
color:#2c4557;
margin:10px 0;
}
.subTitle {
margin:5px 0 0 0;
}
.header ul {
margin:0 0 15px 0;
padding:0;
}
.footer ul {
margin:20px 0 5px 0;
}
.header ul li, .footer ul li {
list-style:none;
font-size:13px;
}
/*
Heading styles
*/
div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 {
background-color:#dee3e9;
border:1px solid #d0d9e0;
margin:0 0 6px -8px;
padding:7px 5px;
}
ul.blockList ul.blockList ul.blockList li.blockList h3 {
background-color:#dee3e9;
border:1px solid #d0d9e0;
margin:0 0 6px -8px;
padding:7px 5px;
}
ul.blockList ul.blockList li.blockList h3 {
padding:0;
margin:15px 0;
}
ul.blockList li.blockList h2 {
padding:0px 0 20px 0;
}
/*
Page layout container styles
*/
.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer {
clear:both;
padding:10px 20px;
position:relative;
}
.indexContainer {
margin:10px;
position:relative;
font-size:12px;
}
.indexContainer h2 {
font-size:13px;
padding:0 0 3px 0;
}
.indexContainer ul {
margin:0;
padding:0;
}
.indexContainer ul li {
list-style:none;
padding-top:2px;
}
.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt {
font-size:12px;
font-weight:bold;
margin:10px 0 0 0;
color:#4E4E4E;
}
.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd {
margin:5px 0 10px 0px;
font-size:14px;
font-family:'DejaVu Sans Mono',monospace;
}
.serializedFormContainer dl.nameValue dt {
margin-left:1px;
font-size:1.1em;
display:inline;
font-weight:bold;
}
.serializedFormContainer dl.nameValue dd {
margin:0 0 0 1px;
font-size:1.1em;
display:inline;
}
/*
List styles
*/
ul.horizontal li {
display:inline;
font-size:0.9em;
}
ul.inheritance {
margin:0;
padding:0;
}
ul.inheritance li {
display:inline;
list-style:none;
}
ul.inheritance li ul.inheritance {
margin-left:15px;
padding-left:15px;
padding-top:1px;
}
ul.blockList, ul.blockListLast {
margin:10px 0 10px 0;
padding:0;
}
ul.blockList li.blockList, ul.blockListLast li.blockList {
list-style:none;
margin-bottom:15px;
line-height:1.4;
}
ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList {
padding:0px 20px 5px 10px;
border:1px solid #ededed;
background-color:#f8f8f8;
}
ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList {
padding:0 0 5px 8px;
background-color:#ffffff;
border:none;
}
ul.blockList ul.blockList ul.blockList ul.blockList li.blockList {
margin-left:0;
padding-left:0;
padding-bottom:15px;
border:none;
}
ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast {
list-style:none;
border-bottom:none;
padding-bottom:0;
}
table tr td dl, table tr td dl dt, table tr td dl dd {
margin-top:0;
margin-bottom:1px;
}
/*
Table styles
*/
.overviewSummary, .memberSummary, .typeSummary, .useSummary, .constantsSummary, .deprecatedSummary {
width:100%;
border-left:1px solid #EEE;
border-right:1px solid #EEE;
border-bottom:1px solid #EEE;
}
.overviewSummary, .memberSummary {
padding:0px;
}
.overviewSummary caption, .memberSummary caption, .typeSummary caption,
.useSummary caption, .constantsSummary caption, .deprecatedSummary caption {
position:relative;
text-align:left;
background-repeat:no-repeat;
color:#253441;
font-weight:bold;
clear:none;
overflow:hidden;
padding:0px;
padding-top:10px;
padding-left:1px;
margin:0px;
white-space:pre;
}
.overviewSummary caption a:link, .memberSummary caption a:link, .typeSummary caption a:link,
.useSummary caption a:link, .constantsSummary caption a:link, .deprecatedSummary caption a:link,
.overviewSummary caption a:hover, .memberSummary caption a:hover, .typeSummary caption a:hover,
.useSummary caption a:hover, .constantsSummary caption a:hover, .deprecatedSummary caption a:hover,
.overviewSummary caption a:active, .memberSummary caption a:active, .typeSummary caption a:active,
.useSummary caption a:active, .constantsSummary caption a:active, .deprecatedSummary caption a:active,
.overviewSummary caption a:visited, .memberSummary caption a:visited, .typeSummary caption a:visited,
.useSummary caption a:visited, .constantsSummary caption a:visited, .deprecatedSummary caption a:visited {
color:#FFFFFF;
}
.overviewSummary caption span, .memberSummary caption span, .typeSummary caption span,
.useSummary caption span, .constantsSummary caption span, .deprecatedSummary caption span {
white-space:nowrap;
padding-top:5px;
padding-left:12px;
padding-right:12px;
padding-bottom:7px;
display:inline-block;
float:left;
background-color:#F8981D;
border: none;
height:16px;
}
.memberSummary caption span.activeTableTab span {
white-space:nowrap;
padding-top:5px;
padding-left:12px;
padding-right:12px;
margin-right:3px;
display:inline-block;
float:left;
background-color:#F8981D;
height:16px;
}
.memberSummary caption span.tableTab span {
white-space:nowrap;
padding-top:5px;
padding-left:12px;
padding-right:12px;
margin-right:3px;
display:inline-block;
float:left;
background-color:#4D7A97;
height:16px;
}
.memberSummary caption span.tableTab, .memberSummary caption span.activeTableTab {
padding-top:0px;
padding-left:0px;
padding-right:0px;
background-image:none;
float:none;
display:inline;
}
.overviewSummary .tabEnd, .memberSummary .tabEnd, .typeSummary .tabEnd,
.useSummary .tabEnd, .constantsSummary .tabEnd, .deprecatedSummary .tabEnd {
display:none;
width:5px;
position:relative;
float:left;
background-color:#F8981D;
}
.memberSummary .activeTableTab .tabEnd {
display:none;
width:5px;
margin-right:3px;
position:relative;
float:left;
background-color:#F8981D;
}
.memberSummary .tableTab .tabEnd {
display:none;
width:5px;
margin-right:3px;
position:relative;
background-color:#4D7A97;
float:left;
}
.overviewSummary td, .memberSummary td, .typeSummary td,
.useSummary td, .constantsSummary td, .deprecatedSummary td {
text-align:left;
padding:0px 0px 12px 10px;
}
th.colOne, th.colFirst, th.colLast, .useSummary th, .constantsSummary th,
td.colOne, td.colFirst, td.colLast, .useSummary td, .constantsSummary td{
vertical-align:top;
padding-right:0px;
padding-top:8px;
padding-bottom:3px;
}
th.colFirst, th.colLast, th.colOne, .constantsSummary th {
background:#dee3e9;
text-align:left;
padding:8px 3px 3px 7px;
}
td.colFirst, th.colFirst {
white-space:nowrap;
font-size:13px;
}
td.colLast, th.colLast {
font-size:13px;
}
td.colOne, th.colOne {
font-size:13px;
}
.overviewSummary td.colFirst, .overviewSummary th.colFirst,
.useSummary td.colFirst, .useSummary th.colFirst,
.overviewSummary td.colOne, .overviewSummary th.colOne,
.memberSummary td.colFirst, .memberSummary th.colFirst,
.memberSummary td.colOne, .memberSummary th.colOne,
.typeSummary td.colFirst{
width:25%;
vertical-align:top;
}
td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover {
font-weight:bold;
}
.tableSubHeadingColor {
background-color:#EEEEFF;
}
.altColor {
background-color:#FFFFFF;
}
.rowColor {
background-color:#EEEEEF;
}
/*
Content styles
*/
.description pre {
margin-top:0;
}
.deprecatedContent {
margin:0;
padding:10px 0;
}
.docSummary {
padding:0;
}
ul.blockList ul.blockList ul.blockList li.blockList h3 {
font-style:normal;
}
div.block {
font-size:14px;
font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif;
}
td.colLast div {
padding-top:0px;
}
td.colLast a {
padding-bottom:3px;
}
/*
Formatting effect styles
*/
.sourceLineNo {
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here