Java程序辅导

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

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439

The aim of this lab is to introduce you to the Eclipse IDE, the integrated development environment you will be using for Software Engineering CITS1220. At the end of the lab, you will be able to write and assess code that meets a set of Java programming conventions.

Eclipse is a Java-based, extensible open source development platform: a framework and a set of services for building applications from plug-in components. Eclipse also provides a plug-in development environment that allows users to build tools that integrate seamlessly with the Eclipse environment.  You can install EasyEclipse Desktop Java Version Easy Eclipse 1.3.1.1 on your own computer (it runs on Windows, Mac or Linux) by downloading a copy from http://www.easyeclipse.org/site/home/

We will also be using Checkstyle in this lab. Checkstyle is a tool that helps programmers to write Java code that complies to Java coding standards. You can install Checkstyle or Eclipse-CS as an Eclipse plugin on your own computer (it runs on Windows, Mac or Linux) by downloading a copy from http://eclipse-cs.sourceforge.net/ choosing  Eclipse Checkstyle Plug-in  5.0.0.200906281855-final. Checkstyle is available as an Eclipse plug-in in the lab.   You will need to install the Beginners style rules for CITS1220, and instructions for doing this are given below, and on the Resources section of the CITS1220 web.

You are responsible for ensuring that all the code you submit for labs and projects in this unit passes the Java conventions for CITS1220.     The rules are available at and install the rules for Eclipse at

Lab Tasks

 

1.    Make a new directory in your Windows home area (the H: drive) for SE1220 (say SE1220).   This will be used for your Eclipse workspace and all lab work.

2.    Start up Easy Eclipse from the shortcut in the Java IDEs directory on the Windows Desktop in CSSE labs.�� All lab instructions are written for Windows and for the Easy Eclipse distribution, so make sure you are working with these versions.

3.    When Eclipse starts, you will be asked to nominate a workspace.   When prompted for your workspace, browse to your new directory H:\SE1220, tick the box to make this the default choice from now on and click OK.

4.    A welcome window comes up the first time you run Eclipse.   Close the welcome window to show the main Eclipse desktop.

5.    Create a new Java project (File > New > Project or use the J+folder icon).   Choose Java Project from the Java folder, click Next and type the project name week2 into the Project name: field.   Click Finish to create the new project .   Click Yes when offered the Java Perspective.

6.    Now download some Java code as follows.   Right click on this link , choose Save Link As and click Save to download the sample code to your desktop.  Then move the file into folder SE1220/week2/src. After that, right click week2 under the Package Explorer and select Refresh. You should see the file DateConverter.java appear in the src directory. (If you don't remember where the folder is, you can find the location by right clicking on week2 under the Package Explorer and select Properties.)

7.      Checkstyle in Eclipse uses a standard set of Java style rules from Sun by default, but we have constructed a cut down version for CITS1220, so you don�t get too overloaded with rules.You now need to load the CITS1220 Beginners rules, so that your workspace and project know about them.To see the types of rules in the full Sun set, jump ahead and try the checking instruction below now.��

8.      Download the CITS1220 Java style rule set to your Eclipse workspace (say H:\SE1220).

9.      Window > Preferences > Checkstyle > New.Choose External Configuration File for Type, CITS1220 Beginners for Name and for Location browse to the file CITS1220StyleRule(Beginner).xml in your workspace (You might need to click the Import... buttonto navigate through the directory to the xml file).   Then press OK to load the new style file, and finally select the CITS1220 Beginners configuration, click on Set as Default and click OK.

10.  Now we use CheckStyle to assess the code.   In the Package Explorer window, double click on DateConverter.java to open the file.   Right click on DateConverter.java and then select Checkstyle> Check Code with Checkstyle. You should see many lines of codes are highlighted and a small magnifying glass icon appear at the same time. It is indicating that particular line of code is violating the style rules. Place the cursor on each icon and you should see the rules that is being violated.

Note: to check that the Beginners project checkstyle rules are being used for any particular Eclipse project, open the project then follow Projects > Propserties > Checkstyle, select CITS1220 Beginners from the Configuration list and click OK.

11.           Correct all of the errors in the method convertYearToDays(int year).     You only need to fix this one method for now.   Each time you make a change, save your Java file, and run Checkstyle again to re-check the code. Use the CITS1220 style study (see lecture handout) as a summary of the rules enforced by CheckStyle. The CheckStyle highlight and icon will both disappear when the correction you have made meets the style rules.

12.           Now we will use Eclipse Formatter to help us correct some of the styling errors. First highlight the method convertMonthToDays(int year, int month). Then use the Eclipse Formatter: Source > Format, or you could use the shortcut key CTRL+SHIFT+F. This should correct most of the layout errors in the method. The formatter will only correct some of the styling errors, refer to the handout for the type of errors that are not corrected by the formatter.

13.           Finally, correct all the remaining errors identified by Checkstyle in DateConverter.java.

14.           Add code to complete the method convertDaysToYear(int day) in the DateConverter. Remember to make sure the code follows styling rules, and utilise existing methods wherever you can.   The TODO lines in the file outline a plan for implementing this function.

15.           Finally, use Violet UML to document the DateConverter class.   Select File > New > Other > Violet UML Editor > Class Diagram, and name a new drawing window DataConverter.class.Violet.   You can now use the drawing tools and editor to construct a class diagram.   Better still, you can simply drag DateConverter.java from the Package Explorer into the drawing window.   Magic! You should now have a class diagram for your Java class.   Create class diagrams for any other Java classes you have developed.

 

Optional Hot Section

This section contains further work for interested students. Make sure the code follows the style rules.

13.  Add code to complete the method convertDaysToMonth(int day, int year)

14.  Add code to complete the method convertDaytoDate(int day)

Hint: Make use of the existing   methods in the class such as convertMonthToDays(int year, int month) and convertDaysToMonth(int day,int year))

15.  Choose a Java program that you have written in another unit. Copy your code into the week2 project and reformat it to comply with the style rules. Submit 2 suitably named versions of your program: the original   unformated version and your formatted code as well.

 

 

 

 

CRICOS Provider Code: 00126G