Java代写 | 4483 Software Technology COLT 2 2019 Assignment 2

使用Java完成一个模拟的Project 

4483 Software Technology 1

COLT 2 2019

Assignment 2  (10% of the unit ) Marks 50

 Total Marks 50 (Part A 35 + Part B 15)

 

Due: Friday Week 11 6th of September 2019 23.59 pm

 

PART A (35 Marks)

The warehouse managers’ helper program

 

GENERAL INSTRUCTIONS

This assignment should be done individually. The assignment consists of writing a program and demonstrating it and submitting it on canvas.

 

Assignment Briefing:

 

At a conceptual level this changes and builds on Assignment1. It removes the interesting discount handling but adds shipping, file reading and ordering complexity.

 

One key difference is that some orders are received as .txt files which must also be processed.

 

The wonderful Elon Musket, in the nation of ‘Tisisoddistan’ has opened a robotic distribution centre called ‘Bakov’ to distribute parts for his Space-hex rockets.

 

In this assignment, assume you are writing a program as part of the ‘Bakov’ distribution centre, which is in turn part of Elon’s vast business empire. Your tiny part is to write a program that takes orders, and then follows up with an invoice.

 

As part of the convoluted tax law in Tisisoddistan (which I made up for the assignment) all parts sold are charged at the shown price plus a 10% VAT. The VAT is a Value Added Tax like Australia’s GST, but administered differently.

 

However, it turns out that one subsidiary the “Blue Fish Space Company” is a registered charity and is not charged VAT.

 

No one can order more than we currently have in stock in the warehouse – as seen in the product table. (You do not need to keep a count of stock sold; nor should you reduce the amount when stock is sold. You can assume that stock is ‘magically’ replenished to the levels in the product table as it is sold – presumably by another program).

 

All inputs must be checked – company Id must be valid and as must product codes.

 

Orders of 0 or less are disallowed and assumed to be errors.

 

Here is a helpful table to show the various tax and discount statuses of the different subsidiaries.

 

Company Information

Company IdFull NamePay TaxPickup

Bay Id

BFSCBlue Fish Space CoNoMERCY
ECPElon Cannon PersonalYesKIT
NAASANAASAYesMERCY
AARGAARGYesKAT
PUBGeneral PublicYesMAIL

Note: PUB is a general public mail order and must be shipped. The order is subject to additional shipping costs. Only the company PUB can ship by mail, all other orders are picked up from the warehouse – no annotation is necessary for them. Products or total orders heavier than 300Kg cannot be shipped and must be picked up by the ordering company. This should be annotated on the invoice.

 

Shipping cost (total KG’s) for the order line (only PUB customers pay shipping cost)

Less than 1.5 KG – $5
1.5kg to 20 kg – $6 plus 55c per kg
Greater than 20 KG – $1.05 per Kg

 

 

The warehouse has only 8 products as shown below in the product table

Product CodeDescriptionPrice $Warehouse LocationMaximum to be ordered *1Weight in kg with packaging
FENGFast Engine12,124.50ENG-89451027   *2
SENGSmall Engine7,000.00ENG-895572
FTFuel Tank7,000.00FT5400     *2
HGAHigh Gain Antenna7,003.11ANT-20017
LWALight Weight Antenna4,950.20ANT51.2
PAPolymer aerogel200.00PA1010.3
AAAA battery$1.34BAT-AA10000.1
AA20AA batteries (20)$14.99BAT-AA201990.4

*1 – Current warehouse stock (Your program does not need to keep count)

*2 – This cannot be sent by mail

Note 3 – AA20 is a pack of 20 AA’s (cheaper in bulk)

Note 4 – HGA is out of stock and can’t be ordered – (should produce a sensible warning message)

Note 5- All parts of the order that can be sent by mail are sent by mail (PUB only).

Note 6- To keep it simple no need to add all weights – postage is per line

 

You program needs to have the following options in a menu which loops

OptionEffect
QQuits the program
CPrints out the table Company Information for testing (which should be the same as the table above, in same order and general format)
OProcess an order from keyboard input

This will need to input:

·      Company Id of the company that’s ordering parts;

·      product code; and

·      number of items ordered.

 

The fields that are input do (Repeat DO!) need to be checked for errors. (You need more sophisticated error handling code than in MT1.)

 

The program must then print the invoice line which shows

·      Company code (Id)

·      Product Code

·      Number of products ordered

·      Cost of one product

·      Gross cost (product cost * num products)

·      Tax (if applicable)

·      Weight (weight of one product * num products)

·      Shipping cost

·      Total cost (product + shipping +tax)

·      An extra line to describe shipping if the  customer is PUB (see my example below)

 

 

FProcess an order from a file

This option will prompt for keyboard input of a file name. The file will contain the order information. The format of the .txt file is shown below

WPrint a Product table (see above for format, see below for example)

 

 

 

Layout of the orders .txt file:

 

On each line is the company Id of the company that’s ordering parts then a comma then

the product code a comma and the number of items ordered.

The files are supposed to be in upper case. (should a lower case character be found you can convert it to upper case safely).

… Format of these lines is repeated till last order

Then on the final line of the file is the word END

There are a minimum of 2 lines in the file the 3rd and subsequent lines are optional the fileay have any number of blank lines after the ‘END’

Your program is expected to handle errors in the file in a sensible way.

 

Example of an orders .txt file (supplied as test1.txt)

AARG,FENG,3

END

 

Second Example of another orders .txt file (supplied as test2.txt)

NAASA,FENG,3

PUB,AA20,3

END

 

 

A simple example worked through – NAASA orders 3 fast engines.

StepDescriptionComputation / Notes
InputThe Company code and nameNAASA
InputThe Product Code and nameFENG
InputThe number of products ordered3
ComputeThe list cost of the product from the tableLookup using FENG
ComputeMultiply by number of products

 

3 * 12,124.50

= 36,373.50

ComputeThe Tax paid

 

10% of 36,373.5

=3,637.35

ComputeThe Tax Added to price

 

36,373.5 + 3,637.35

= 40,010.85

ComputeCompute the final cost of the order=40,010.85
PrintDisplay the order lineThe number of products ordered 3

Cost of 1 product 12,124.50

Gross cost 36,373.50

Tax (if applicable) 3,637.35

Weight 3,081

Shipping cost 0

Total cost 40,010.85

 

 

 

 

Another example

StepDescriptionInput or OutputComputation / Notes
1The Company codePUBIt’s mail order folks
The Product Code and nameAA20
The number of products ordered3
Lookup cost14.99

Multiply by number of products

14.99*3 = 44.97

Tax is 10%Tax = 44.97 *0.1 = 4.497

Rounds to 4.50

Weight is (lookup)0.40.4 *3 = 1.2kg
Shipping is5$Less than 1.5 kg
Shipping+tax+gross cost =5+4.50+44.97 = 54.47
Compute the final cost of the order=54.47 + 40,010.85

 

Giving 40,065.32

Will be minor rounding errors

 

      

HINTS

 

Look at the supplied code;

 

Create some (like a lot) of additional test cases. See the example test plan I provide.

 

Get it accurate first, then tidy it up. ‘doubles’ can print nicely with %11.2f format in printf.

 

Look at the example run further down in this document.

 

Sample Runs

 

 

 

 

 

 

 

 

 

 

PART B (15 Marks)

 

Basic Swing Form

 

Introduction

 

This part of your main assignment should be done individually. This assignment consists of writing a program and demonstrating it and submitting it on Canvas.

 

NOTE: You cannot do this using drag and drop in eclipse or some other java development environment. You are warned that;  I will put coding questions in the exam that assume you wrote this swing form yourself, manually coding the listeners and attaching them to buttons. You are unlikely to learn how to do this if you use drag and drop GUI builders.

 

GENERAL INSTRUCTIONS

 

Write a simple swing form that has the following features and looks (more or less) like the following:

 

It has three buttons, each of which does one thing; Add, Subtract, Concatenate.

It has 1 checkbox ‘Facebook’ which modifies the add button so it displays “Facebook”, thus proving Facebook is more interesting than Math. (Joke)

 

 

Here are examples of each function

 

Add

 

 

Subtract

 

 

 

Concatenate (example 1)

 

 

Concatenate (example 2)

 

Add with Facebook checked

 

 

Hints :

 

  1. First define the GUI class which extends Jframe
  2. Set the frame size
  3. Set it to visible
  4. Add the 3 or 4 JLabels (I used a JLabel for ===== which is optional)
  5. Test it
  6. Add the 2 JTextField (input boxes)
  7. Test it
  8. Add the 3 buttons
  9. Test it
  10. Add the Facebook checkbox
  11. Test it
  12. Write 1 listener class for Add (which checks the checkbox)
  13. Connect the listener to the button
  14. Test it
  15. Write 2 more listener classes for Subtract and Concatenate
  16. Connect the listener to the button
  17. Test it
  18. Drink Vanilla coke (optional step)
  19. Fix formatting of the output
  20. Add a title to jframe
  21. Tidy it up
  22. Test it
  23. Show your tutor (get 5 easy marks)

 

Below are some useful code fragments:

 

// *******************************************************

 

getContentPane().setLayout(null);

setTitle(“Assignment PartA”);

 

// *******************************************************

 

 

String text = text1.getText();

try

{

val1 = Double.parseDouble(text);

 

}

catch (NumberFormatException e)

{

val1=0;

rc=false;

JOptionPane.showMessageDialog(null, “Enter a valid double precision number please”,

“<< First Number Error >>”,

JOptionPane.ERROR_MESSAGE);

}

 

// *******************************************************

 

public class bAddAction implements ActionListener

{

public void actionPerformed (ActionEvent event)

{

///// —————–

 

////// Lines deleted here that parsed the JTextFields into val1 and val2

 

///// —————–

 

if (rc)

{displayText4.setText(String.format(“%12.4f”,(val1 + val2)));}

else

{displayText4.setText(“0”);}

 

}

}

 

// *******************************************************

 

int posX =260;

JButton buttonAdd = new JButton(“Add”);

buttonAdd.setLocation(posX,30);

buttonAdd.setSize(110,20);

buttonAdd.addActionListener(new bAddAction());

getContentPane().add(buttonAdd);

 

 

// *******************************************************

 

 

 


程序代写代做C/C++/JAVA/安卓/PYTHON/留学生/PHP/APP开发/MATLAB


本网站支持淘宝 支付宝 微信支付  paypal等等交易。如果不放心可以用淘宝交易!

E-mail: [email protected]  微信:dmxyzl003


如果您使用手机请先保存二维码,微信识别。如果用电脑,直接掏出手机果断扫描。

发表评论