Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

GENERAL INSTRUCTIONS This assignment should be done individually. The assignment consists of two parts one part is a written submission of code you have written, test plan and test runs (Part A, worth...

1 answer below »

GENERAL INSTRUCTIONS

This assignment should be done individually. The assignment consists of two parts one part is a written submission of code you have written, test plan and test runs (Part A, worth 25 marks, details in this document), the other writing a swing program and demonstrating it (part B worth 5 marks details to be provided Tuesday week 7).

The main purpose of this assignment is for you to code a program in Java that solves a problem, from a fictional world of the kerbal space program.

You can ask for help during the tutorials and your tutor will be happy to assist; but they are instructed to try to guide you through finding a solution yourself rather than giving you an answer.

Students should be aware that I may do some kind of plagiarism check.

Note code must be in BlueJ code written and submitted in any other Java environment may not be able to be marked.

This assignment is marked by as a submission of a single zip file. It should be submitted to Canvas by its due date (see above). You need to submit:

· The java program code as a bluej project directory;

· A test plan;

· Documented results of your test plan;

· The results of mandatory test runs; and finally

· A short reflection report on what you learned.

There are no resubmission options for this assignment.

The grade you will achieve will depend on the functionality of the submitted program as shown in the marking rubric later in this document.

Assignment Briefing:

For the purposes of the assignment we will assume the following:

You are writing a program for the Kerbal Space Committee. This is the body of kerbals who’s job it is to hand out contracts and grant money to companies (like the real world spaceX) to do space science and exploration.

Each proposal for a mission includes the following details:

Item

Sponsor

Can be more than one word

Payload type

From the payload table

Value/Cost in $

Integer in $

Scientific Value

In words

None, Low, Medium High or VHigh

Publicity value

In words

None, Low, Medium High or VHigh

Description

Will usually be more than one word

The highly efficient Kerbal Space Committee converts the filled out proposal forms into a numerical value as follows:

If the Sponsor is Kerbal Trump or Science Institute

Add 2 point to the value

If the scientific value is low

Add 1 to the value

If the scientific value is medium

Add 2 to the value

If the scientific value is high

Add 3 to the value

If the scientific value is vhigh

Add 5 to the value

If the Publicity value is Low

Add 1 to the value

If the Publicity value is medium

Add 1.5 to the value

If the Publicity value is high

Add 2.2 to the value

If the Publicity value is vhigh

Add 3.5 to the value

If the payload is 3c and publicity high or vhigh

-1.3 to the value

To risky to loose a kerbal

If the payload is 1c and publicity high or vhigh

-1.1 to the value

To risky to loose a kerbal

If the Sponsor is Mega Corp

+0.9 to value

Gives a lot of election funds to political party

If the payload is taxable

Multiply final value by 1.1 and add 1

Get government revenue,

Done after all other tests

All the proposals to be assessed by the committee are stored in a file laid out as follows; each proposal is spread across 2 lines and has 6 values. For each proposal a score is calculated the scores are compared and the one with the highest score is then approved. If the highest one is not unique (ie two have the same highest score) the first one in the file is taken. (ie the one you read in first).

Sponsor, Payload type, Description

cost$, Science Value , Publicity value

Example Proposals file containing three proposals

Kerbal Trump,LG, Lunar gateway Station

45000,Vhigh,Vhigh

University Of Kanberra,CS,Satelite Internet to Kanberra

19,000,Low,Low

Iz Getting HOT,SS, Global Warming Temperature monitor

18000,VHigh,low

Launch Payloads

ID

Name

Destination

Taxable

SS

Scientific Satellite

High Orbit

No

CS

Communication Satellite

Geosynchronous Orbit

Yes

3C

3 Person Capsule

Low Orbit

Yes

1C

1 Person Capsule

Low Orbit

Yes

SM

Small Space Station

Low Orbit

No

PP

Planetary Probe

Planetary Orbit

No

LG

Lunar gateway

Lunar orbit

No

MR

Moon Rover

Lunar Surface

No

The only thing common to Mt1/Mt2 is a partial list of payloads.

The file can contain upper and lower case, so low, Low and LOW are considered the same

Hint: It turned out to be fairly easy to do test cases in Excel

What you must do:

a) Write a test plan enough test cases to convince yourself that the code works;

b) Write the code;

c) Test the code and document the results of the test

d) Debug the code

e) Test the code again and document the results of the test

f) Debug the code again

g) Repeat steps E and F till you are confident of your programs accuracy

h) Finally when you are happy with it Run the mandatory test cases and document the results

i) Write a report (or reports) that contain the following

a. Your test plan;

b. Documentation of your test plan, and documenting its results;

c. Evidence of you running the mandatory test runs and screenshots of the results;

d. A short reflection report-on what you have learned; and

e. An optional feedback paragraph to me which is not marked.

j) Finally zip all documents (including your source code and the bluej project directory) into a single zip file and load them onto Canvas.

What your program must do:

1. It must display a menu with 4 options shown below you can add extra debugging options if you desire;

2. Option:It must have an exit option;

3. Option:It must have a compute value option;

a. Note that this option does not include input of the description or of the cost (this is just to make your life easier)

4. Option:It must have a Process Proposals file option;

5. Option:It may have (for the extra marks) a ‘process many files’ option.

a. The recommendation is for the highest of all processed files

b. The list must include the filename of the proposal

6. The menu must loop so it can do repeated calculations without restarting;

7. The output must be well formatted in this case both a straightforward answer and also list of the proposals and their score;

8. It should edit check all input (the file and any keyboard input), so it does not crash on an error but instead gives a suitable error message.

Example Test Case 1

Sponsor:Kerbal Trump,

Payload: LG

Scientific Value: Vhigh

Publicity Value: Vhigh

Value

Set proposal value to 0

0

If the Sponsor is Kerbal Trump or Science Institute +2

2

Science value Vhigh

2+5 = 7

Publicity value Vhigh

7+3.5 = 10.5

If the payload is 3c and publicity high or vhigh

10.5

If the payload is 1c and publicity high or vhigh

10.5

If the Sponsor is Mega Corp

10.5

If the payload is taxable (no)

10.5

Test Case 2

The following test case is worked through for you for the option ‘a compute value:

Sponsor:University Kanberra,

Payload: CS

Scientific Value: low

Publicity Value: low

Value

Set proposal value to 0

0

If the Sponsor is Kerbal Trump or Science Institute

0

Science value low

1

Publicity value low

1+1

If the payload is 3c and publicity high or vhigh

2

If the payload is 1c and publicity high or vhigh

2

If the Sponsor is Mega Corp

0

If the payload is taxable (no)

2*1.1+1 = 2.2+1=3.2

Test Case 3

Process file testcaseK1.txt

Test Case 4

Process file testcaseK2.txt

Test Case 4 (for optional ‘process many files’ option)

Process file testcaseK2.txt and file testcaseK3.txt


Mandatory Testing

You must run and evidence the output of the following tests:

Mandatory Test 1 - compute value

Fred,3c,Science=Vhigh,Publicity=low

Mandatory Test 2 - compute value

Science institute,SM, Science=Vhigh, Publicity=None

Mandatory Test 3 - Process Proposals

Run File testMandA1.txt

(to be put on web site Wednesday 11/7/18)

Mandatory Test 4 - Process Proposals

Run File testMandA2.txt

(to be put on web site Wednesday 11/7/18)

Mandatory Test 5 - Process Proposals

Run File testMandA3.txt

(to be put on web site Wednesday 11/7/18)

Optional Test 6 - Process Proposals

(for the Multiple file option)

Run Files testMandO1.txt, testMandO2.txt

(to be put on web site Wednesday 11/7/18)

Optional Test 7 - Process Proposals

(for the Multiple file option)

Run File testMandO2.txt, testMandO3.txt, testMandO1.txt, in that order

(to be put on web site Wednesday 11/7/18)


Sample runs


Marking (This assignment part is worth 25 marks).

Marking Rubric

Marks

Feature

8

Good test plan and evidence of testing

6

Your program code, accuracy, functionality and formatting

3

Reflection Report

5

Results of mandatory testing

3

For the correct running of the ‘process many files’

-1 to -3 if the program fails to check the range its input

-2

For the first mandatory test that’s wrong

-6

If more than 1 mandatory test is wrong

-2

Program crashes during our testing but it’s an isolated case

Maximum of 12.5 marks for assignment overall

Program fatally crashes, wont compile or has a significant number of gross errors

Late submission

5% per day up to 1 week then a mark of 0

Watch the web site for late class wide extensions that may be given

Answered Same Day Jul 17, 2020

Solution

Meenakshi answered on Jul 22 2020
139 Votes
project/GUIProgram.java
project/GUIProgram.java
import java.awt.EventQueue;
import java.util.*;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JTextField;
import javax.swing.*;
import javax.swing.event.*;
import java.util.List;
import java.awt.event.*;
import java.io.*;
import java.awt.Dimension;
import java.awt.*;
public class GUIProgram {
    private JFrame frame;
    private JTextField textField;
   private JList datalist;
   private JList cList;
 String txt1="hello";
             
      String tt="Moon";
      String tt1="moon";
    /**
     * Launch the application.
     *
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    GUIProgram window = new GUIProgram();
                    window.frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
    /**
     * Create the application.
     *
    public GUIProgram() {
        initialize();
    }
    /**
     * Initialize the contents of the frame.
     *
    private void initialize() {
  
 String txt1;
        frame = new JFrame();
        frame.setBounds(10, 10, 450, 700);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().setLayout(null);
         JRadioButton yesButton   = new JRadioButton("Integreated Inetegral", true);
        JRadioButton noButton    = new JRadioButton("Ke
odyne ");
        JRadioButton maybeButton = new JRadioButton("Rockomax Conglomerate");
        
              
 Assume default encoding.
           
            
 Note that write() does not automatically
            
 append a newline character.
        
        
... Create a button group and add the buttons.
        ButtonGroup bgroup = new ButtonGroup();
        bgroup.add(yesButton);
        bgroup.add(noButton);
        bgroup.add(maybeButton);
        yesButton.setBounds(3, 47, 136, 44);
          frame.getContentPane().add(yesButton);
                noButton.setBounds(3, 87, 136, 44);
          frame.getContentPane().add(noButton);
                maybeButton.setBounds(3, 147,176, 44);
          frame.getContentPane().add(maybeButton);
        
        JLabel lblName = new JLabel("COST");
      
        lblName.setBounds(93, 564, 46, 14);
        frame.getContentPane().add(lblName);
      DefaultListModel listModel = new DefaultListModel
();
       
      listModel.addElement("SS High O
it");
      listModel.addElement("CS Geosynchronous O
it");
      listModel.addElement("3C  Low O
it");
      listModel.addElement("1C  Low O
it");
      listModel.addElement("SM  Low O
it");
      listModel.addElement("PP  Planetary O
it");
      listModel.addElement("LG Lunar o
it");
      listModel.addElement("MR Lunar Surface");
cList = new JList
(listModel);
cList.addListSelectionListener(new ListSelectionListener() {
@Ove
ide
public void valueChanged(ListSelectionEvent e) {if (!e.getValueIsAdjusting()) {final List selectedValuesList = cList.getSelectedValuesList();
System.out.println(selectedValuesList);
}}});
      JLabel t= new JLabel("PayLoad");
          
         t.setBounds(0,270,85,20);
        cList.setBounds(100,270,65,170);
                 frame.getContentPane().add(cList);
         frame.getContentPane().add(t);
     JLabel jf= new JLabel("Target");
String sa
ay[]={"Moon","Mars","Venus","Phobos"};
jf.setBounds(0,470,85,30);
     frame.getContentPane().add(jf);
     
         
 l1.addElement("Item4");  
         
 JList list = new JList
(l1);
         
  list.setBounds(100,300, 75,75);  
         
  frame.getContentPane().add(list);
            JComboBox   cbox = new JComboBox(sa
ay);                         
            cbox.setBounds(100,470, 85,35);  
           frame.getContentPane().add(cbox);
      
    
 obj;
    
 = cbox.getSelectedItem(); 
    
 Set a new value
        cbox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent arg0) {
            
Do Something
          Object  obj = cbox.getSelectedItem(); 
        tt1=""+obj;   
        System.out.println("tt1"+tt1);
    
        }
    });
         JButton btnSubmit = new JButton("DONE");
           btnSubmit.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                JOptionPane.showMessageDialog(null, "Data Submitted");
       txt1+="Ke
al Space Commettee select the proposal";
        ScrollingTextArea st= new ScrollingTextArea(txt1);
      st.mainstr(txt1);
      try {
        String p= textField.getText();
        System.out.println("hello"+p);
String ta="\n";
    String  txt11= ta+ta+"nKe
al Space Committee is pleased to announce the funding for the project to study the   "+ tt+"  has been approved   .";
String txt2=ta+"       The project will involve launching a Scientific Satellite payload to High O
it at an expected cost of   $"+ p;
String txt3=ta+"        The winning contractor is"+txt1;
      AppendFileDemo ap= new AppendFileDemo();
      ap.fileappend(txt11);
            ap.fileappend(txt2);
                  ap.fileappend(txt3);
                  
            }catch(Exception e){            System.out.println(
                "E
or writing to file ");
            
 Or we could just do this:
            
 ex.printStackTrace();
            
            }
            }
        });
        btnSubmit.setBounds(93, 621, 89, 23);
        frame.getContentPane().add(btnSubmit);
        
        textField = new JTextField();
        textField.setBounds(204, 564, 167, 20);
        frame.getContentPane().add(textField);
        textField.setColumns(10);
    
         maybeButton.addItemListener(new ItemListener() {
         public void itemStateChanged(ItemEvent e) {         
            txt1+=": Rockomax Conglomerate" ;
            
+ (e.getStateChange()==1?"checked":"unchecked");
         }           
      });
         noButton.addItemListener(new ItemListener() {
         public void itemStateChanged(ItemEvent e) {         
           txt1+="Ke
odyne " ;
            System.out.println(txt1);
      
           
;+(e.getStateChange()==1?"checked":"unchecked");
         }           
      });
         yesButton.addItemListener(new ItemListener() {
         public void itemStateChanged(ItemEvent e) {         
            txt1="Integreated Ineteg...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here