Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
Assignment 2 – Classes and Objects UNSW Blogs Home UNSW Wikispaces UNSW Website MyUNSW RSS COMP1400 – Programming for Designers Class announcements for Programming for Designers Assignment 2 – Classes and Objects Posted by Claude on September 5th, 2013 · Assignments NOTE: check this web site regularly for updates and clarifications to the assignment specification. Due Date: Sunday week 8 (23:59:59 22 September 2013) ChangeLog: 11-09-2013: Submission for Assignment 2 enabled Task Suppose you are designing a program for an automated teller machine. The ATM generates transactions that are sent to the banks central computer for processing. In this assignment, you will create two classes, “Account” and “Transaction”. An Account object should have a unique account number, which can be represented by an integer, and a balance. Initially the balance is zero. A Transaction object should have an amount being transacted and a reference to the Account class associated with the transaction. Here is an example of the two classes being invoked: /** * This class contains a main method that calls methods in the classes you will write. * * @author (your name) * @version (a version number or a date) */ public class RunTransactions { static void main() { // Create two new accounts with the given account numbers Account fred = new Account(1234); Account jim = new Account(6778); // Provide accessor methods for account information. int accountNumber = fred.getAccountNumber(); float balance = fred.getBalance(); // Transactions consist of an account reference and an amount Transaction t1 = new Transaction(fred, 20); Transaction t2 = new Transaction(jim, 10); Transaction t3 = new Transaction(jim, -20); // Transactions must contain a "process" method that is called to // actually perform the transaction. // A transaction should not be allowed if it results in a negative balance. t1.process(); t2.process(); t3.process(); // Print out a report of the account balance. // The format should be like this: Account 6778 has balance $20.0 fred.report(); jim.report(); } } Download this file. It contains a BlueJ project with just the RunTransactions class. You must create your own Account and Transaction classes. You can create whatever fields and methods you think appropriate but you must provide methods that can be called exactly as above. The report method should print out a simple message giving the account number and balance. The format should be Account has balance $ For example, the output of the reports from the above sample code should be: Account 1234 has balance $20.0 Account 6778 has balance $10.0 You will learn about main methods and the static qualifier in later lectures. For now, you only need to know that when you right click on the RunTransactions class, you will see an item in the menu void main(). Clicking on this will run the main method, which will call your code. You may change the main method to test your code with different combinations of accounts and transactions. Only remember that you must use exactly the same names of classes and methods and the types of arguments are return values must be identical. When you submit your assignment, we test your code with different main methods. Submission instructions You will submit your assignment to the Give automated marked system. From within your assignment 2 BlueJ project, select Project -> Create Jar File… In the Dialog Box that appears: Set “Main Class” to none Ensure “Include Source” is checked Leave “Include Bluej project files” unchecked Press “Continue” Save the filename as “assignment2.jar” Open a web browser and go to the give web site Log-in with you Z-Pass Either enter “COMP1400” in for the course, or select COMP1400 from the drop down menu and press “Search for Assignments”. Note COMP1400 students may need to enter “COMP1400” instead of selecting COMP1400 if the assignment is not listed Select “assignment2” from the next drop down menu and press “Upload my Assignment” Accept the student declaration Press “Choose File” and select the “assignment2.jar” file that you saved in step 4 Press “Submit my Files” Wait for the page to completely load. Then carefully read the output. If the assignment is successful you should see the following lines: Checking your submission... Checking for Account.java Account.java Compiled Sucessfully Checking for Transaction.java Transaction.java Compiled Sucessfully Sucessfully compiled against sample RunTransactions.java All files are OK If the page doesn’t load properly, that is OK just submit the assignment file again. If you see the final line, everything is good. Otherwise check the output to see what went wrong and resubmit. Submission notes: You can submit as many times as you wish, even after the deadline. Only your last submission will be marked. Make sure you name everything the as instructed, including the classes (“Account” and “Transaction”) the submission file (“assignment1.jar”) or the submission will not work. If you have any problems with submission, email the class account Marking Scheme The maximum mark for this assignment is 10. Marks will be awarded as follows: Performance (6 marks) – for a program that produces the correct results under all tests Style (2 marks) – for the structure of your classes, layout and readability Comments (2 marks) – for a well commented program Email to friend Stay updated Tags: No Comments so far ↓ There are no comments yet...Kick things off by filling out the form below. You must log in to post a comment. Pages Course Outline for Semester 2, 2014 For Tutors Lab Times Lecture Notes and Example Files Software Weekly Quizzes Search Categories Announcements Assignments Lab Lectures Uncategorized Links BlueJ web site Submit/Collect Assignments View Marks Staff Claude Sammut (Lecturer) Timothy Wiley (Admin/Tutor) Troy Lenger (Tutor) Sam Ipsen (Tutor) Meta Log in Entries feed Comments feed WordPress.org UNSW Blogs User Tools Username and Password:          Lost your password? COMP1400 – Programming for Designers Terms of Use Privacy Policy Copyright and Disclaimer Accessibility Acknowledgements UNSW Sydney NSW 2052 Australia Telephone +61 2 9385 1000 UNSW CRICOS Provider Code 00098G ABN 57 195 873 179 Design by jokay