September 30, 2013

How to create javadoc using eclipse ide

How to create developer documentation for a java project


Documentation Comments are essential for every source code in industrial projects. Documentation comments represented by ( /** … */) are unique to java. You can create html developer document for your project once you properly comment your code. Here ,i am going to show you how to create javadoc for your project.

Create a java project in eclipse, Copy and paste the below code to your source folder
/**
* Filename :  ArithmeticOperations.java
* Author   :  belazy1987atgmail.com
* Date      :  September 19 1987
* Description : A java program that shows Basic Arithmetic Operations
*/

/**@author nick +Karthick Rajendran 
 * @version 1.0
*/
public class ArithmeticOperations {
/**  To store answers with double DataType
 */
private double answerDouble = 0.0d;
/**
 *   To store answers with float DataType
 */
private float answerFloat = 0.0f;
/** To store answers with int DataType
 */
private int ansInt = 1;
/** addition() is used to add two variables
 *  @param value_one  first parameter
 *  @param value_two  second parameter
 *  @return answerDouble  returns the sum of value_one and value_two
 */
private double addition(double value_one, double value_two) {
 answerDouble = value_one + value_two;
 return answerDouble;
}

/** subtraction() is used to subtract and return the result
 *  @param value_one first parameter
 *  @param value_two second parameter
 *  @return answerFloat returns the difference of value_one and value_two
 */
private float subtraction(float value_one, float value_two) {
 answerFloat = value_one - value_two;
 return answerFloat;
}

/** multiplication() is used to multiply two values
 *  and return the result
 *  @param value_one first parameter
 *  @param value_two second parameter
 *  @return ansInt returns the product of value_one and value_two
 */
private int multiplication(int value_one, int value_two) {
 ansInt = value_one * value_two;
 return ansInt;
}

/**division() is used to division
 *  and return the result
 *  @param value_one first parameter
 *  @param value_two second parameter
 *  @return ansInt returns the quotient after dividing value_one with value_two
 */
private int division(int value_one, int value_two) {
 ansInt = value_one / value_two;
 return ansInt;
}

/** showDetails() is used to display the output
 *  @param ansAdd  Output of addition
 *  @param ansSub  Output of subtraction
 *  @param ansMul  Output of multiplication
 *  @param ansDiv  Output of Division
 */
private void showDetails(double ansAdd, float ansSub, int ansMul, int ansDiv) {
 System.out.println(" Addition : " +ansAdd);
 System.out.println(" Subtraction : " +ansSub);
 System.out.println(" Multiplication : " +ansMul);
 System.out.println(" Division : "+ansDiv);
}

/**
 * main() function
 * @param str user can pass parameters to main through command prompt
 */
public static void main(String[] str) {
 ArithmeticOperations arithmeticOperation = new ArithmeticOperations();
 double ansAdd = arithmeticOperation.addition(10.0,20.0);
 float ansSub = arithmeticOperation.subtraction(20.8f,12.3f);
 int ansMul = arithmeticOperation.multiplication(200,10);
 int ansDiv = arithmeticOperation.division(100,10);
 arithmeticOperation.showDetails(ansAdd,ansSub,ansMul,ansDiv);
}

/**
 *  belazy1987atgmaildotcom
 */
}

read more 
 
 
Created a html document for the project you had coded 
 
 Thanking you.........

September 27, 2013

How to add css to struts2

 How to add css to struts2
Adding css file to struts

<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><tiles:insertAttribute name="title" ignore="true" /></title>
<link href="<s:url value ="/css/Theme.css"/>" rel="stylesheet" type="text/css"/>
</head>

September 19, 2013

How to reduce coupling in java

 

How to reduce coupling in java

 Description : This examples shows how the concept of interface in java helps to reduce the coupling between classes/ decoupling the classes, Inversion of control, Removing dependency injection

uml diagram example in java- How to reduce coupling
UML Diagram

The concept is very simple. We are just removing the dependencies of class in another class. Let us check how will do this. By doing this project maintenance will be very easy since there is no dependencies. so please try this code

Copy and paste this source code :
This program shows interface example in java

EmployeeInterface.java
/**
* FileName : EmployeeInterface.java
* Author : belazy1987atgmailcomcom
* Date : September 19 1987
* Description : Interface of the project
*/
package com.nick.Interface;
/**
* @author Oscar
* Implementing Employee Interface to types of employees in java
*/
public interface EmployeeInterface {
/**
* basic salary of the employee
*/
int BASICS = 5000;
/**
* house rent allowance for an employee
*/
int HR = 3000;
/**
* Traveling allowance for an employee
*/
int TA = 2000;
/**
*
*/
int DA = 4000;
/**
* @return int
* abstract method for getting the salary
*/
public int getSalary();
/**
*
* @return String
* abstract method for finding the desingation of employee
*/
public String getDesignation();
}
HumanResourceManager.java
/**
* FileName : HumanResourceManager.java
* Author : belazy1987@gmail.com
* Date : September 29 1987
* Description : Represents the details of Human Resource Manager
*/
package com.nick.Interface;
/**
* @author Oscar
*
*/
public class HumanResourceManager implements EmployeeInterface {
/**
* @return string
* Defines the desingation of the employee
*/
@Override
public String getDesignation() {
String designation = ” HumanResourceManager”;
return designation;
}
/**
* @return int
* calculate the salary of the employee (basic + hr)
*/
@Override
public int getSalary() {
int salary = BASICS + HR;
return salary;
}
}
BusinessAnalyst.java
/**
* FileName : BusinessAnalyst.java
* Author : menijesh@gmail.com
* Date : September 29 1987
* Description : MainClass of project
*/
package com.nick.Interface;
/**
* @author Oscar
*
*/
public class BusinessAnalyst implements EmployeeInterface{
/**
* @return string
* defines the designation of the employee
*/
@Override
public String getDesignation() {
String designation = “BusinessAnalyst”;
return designation;
}
/**
* @return int
* calculate the salary of the employee (basic + hr + da)
*/
@Override
public int getSalary() {
int salary = BASICS + HR + DA ;
return salary;
}
}
MarketingStaff.java
/**
* FileName : MarketingStaff.java
* Author : menijesh@gmail.com
* Date : September 29 1987
* Description : Represent the details of marketting staff
*/
package com.nick.Interface;
/**
* @author Oscar
*
*/
public class MarketingStaff implements EmployeeInterface {
/**
* @return string
* defines the designation of the employee
*/
@Override
public String getDesignation() {
String designation = “Marketing”;
return designation;
}
/**
* @return int
* calculate the salary of the employee (basic + hr + ta)
*/
@Override
public int getSalary() {
int salary = BASICS + HR + TA;
return salary;
}
}
MainClass.java
/**
* FileName : MainClass.java
* Author : menijesh@gmail.com
* Date : September 29 1987
* Description : MainClass of project
* Main Idea of the project is to describe how
* interface works and how to reduce coupling
*/
package com.nick.Interface;
/**
* @author belazy1987@gmail.com
* Working with interface in java
*/
public class MainClass {
/**
* @param cmdArg
*/
public static void main(String[] computerScience) {
EmployeeInterface employeeInterface = null;
employeeInterface = new HumanResourceManager();
System.out.println(“Designation :”+employeeInterface.getDesignation() +” and Salary :”+employeeInterface.getSalary());
employeeInterface = new BusinessAnalyst();
System.out.println(“Designation :”+employeeInterface.getDesignation() +” and Salary :”+employeeInterface.getSalary());
employeeInterface = new MarketingStaff();
System.out.println(“Designation :”+employeeInterface.getDesignation() +” and Salary :”+employeeInterface.getSalary());
}
}

The Above program is an example for interface in java. Why java doesnt support multiple inheritence?

This example shows how to reduce couple or enable loose coupling through concept of interface in java. 

 



Facebook comments