Java程序辅导

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

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
Assignment 3 – DRAFT UNSW Blogs Home UNSW Wikispaces UNSW Website MyUNSW RSS COMP1400 – Programming for Designers Class announcements for Programming for Designers Assignment 3 – DRAFT Posted by malcolmr on September 19th, 2012 · Uncategorized In this assignment you will be implementing a simple job queue using objects and array lists. Due date: Midnight Sunday Oct 14 (end of week 12) Topics covered This assignment covers the following ideas: OO design: Abstraction and encapsulation Implementing a class with fields, constructors and accessor methods, Handling collections of objects with ArrayLists, Implementing state using fields and mutator methods, Using the null object to represent “nothing”. The task You need to implement two classes Job and JobQueue. The Job class The Job class is a simple data structure containing: The job name (a String) The duration of the job in seconds (a positive integer). You need to implement a class called Job with appropriate fields to store this data. You also need to implement: A constructor: Job(String name, int duration) which initialises the fields to the given values. Accessor methods: getName() and getDuration(). which return the field values. A run() method which prints “JOB COMPLETE: ” followed by the name of the job. E.g. The code: Job job = new Job("Wash the car.", 100); job.run(); should print: JOB COMPLETE: Wash the car. The JobQueue class The JobQueue class implements a queue of jobs. When you create the queue it is initially empty. You can add jobs to the end of the queue. You can also add run time to the queue. When you run the queue, any available run time is used to execute jobs in the order they are added. As each job is completed, it is moved to the complete jobs list. So for example, starting with an empty queue: Add a job “A” that takes 20 seconds. Add a job “B” that takes 10 seconds. Add a job “C” that also takes 10 seconds. Add 25 seconds to the clock. Run the queue: Job A is completed. 5 seconds remain on the clock. Job B is now the current job. There is not enough time to complete this job, so the queue stops. Add another 20 seconds to the clock, making the total 25. Run the queue: Job B is completed. 15 seconds remain on the clock. Job C is completed. 5 seconds remain on the clock. The jobQueue is now empty, so it stops with 5 seconds left on the clock You need to implement: The JobQueue class with appropriate fields. A constructor with no parameters than initialises the pending and completed queues to empty and the clock to zero. Accessor methods: getPendingJobs() which returns the list of jobs that have not been completed (including the current job) getCompletedJobs() which returns the list of jobs that have been completed. getCurrentJob() which returns the job at the front of the pending queue, or null if the queue is empty. getClockTime() which returns the amount of time left on the clock (as an integer) getTotalDuration() which returns the total duration of all the pending jobs. Mutator methods: addJob(Job job) which adds a Job to the end of the Queue. addTime(int seconds) which adds the specified number of seconds to the clock. runOne() which runs the first job on the queue if there is enough time on the clock. runAll() which runs all the jobs on the queue in order until it runs out of time. Sample solution We are not providing a skeleton solution for this assignment as we will be testing that you are able to write your own method signatures following the description above. However it is important that you follow the specification as closely as possible. To help in this, we have provided a sample solution as a BlueJ project with the source code removed. Please check carefully to make sure your program works exactly the same as the sample solution. Submission From within your assignment 3 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 “Assignment3.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 and press “Search for Assignments”. Select “Assignment3″ from the next drop down menu and press “Upload my Assignment” Accept the student declaration Press “Choose File” and select the “Assignment3.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 JobQueue.java JobQueue.java Compiled Sucessfully All files are OK ================================================ If the page doesn’t load properly, that is OK just submit the assignment file again. If you don’t get the above output 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 and the submission file or the submission will not work. If you have any problems with submission, email the class account. Include exact details of any error messages you get. 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