Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Need some guidance with J Unit Tests

$
0
0
/**
 * Abstract Class Employee
 * @author Prabhdeep Singh
 *
 */
public abstract class Employee {
	protected int id; //  id
	protected double weeklyPay; // weeklyPay

	abstract double calculateWeeklyPay(); // abstract method
/**
 * Constructor of the public abstract class Employee
 * @param id
 */
	public Employee(int id) // takes an int as a argument
	{
		this.id=id;
	}
/**
 * Void Method
 * @param id
 * 
 */
	public void setId(int id) // takes int as an arguement
	{
		this.id=id;
	}
/**
 * Returns an int of arguement ID
 * @return Id
 */
	public int getId() // returns the id arguement
	{
		return id;
	}
/**
 * Converts to string and returns a string
 */
	
	public String toString() // toString method
	{
		return id+" has a weekly pay of "+weeklyPay;
	}
/**
 * Returns the weeklypay
 * @return weeklyPay
 */
	
	public double getWeeklyPay() // getter method
	{
		return weeklyPay;
	}
	

	}

/**
 * Manager extends Employee
 * @author Prabhdeep Singh
 *
 */
public class Manager extends Employee
{
	
	/**
	 * Manager Constructor takes in arguements and calls superclass
	 * @param id
	 * @param weeklyPay
	 */
	public Manager(int id, double weeklyPay) // Constructor
	{
		super(id);
		super.weeklyPay=weeklyPay;
	}
	
	public String toString() // returns a String
	{
		return "Manager "+super.toString();
	}
	
	public double calculateWeeklyPay() // calculates weeklypay
	{
		return super.weeklyPay;
	}
	
}



What code should i write in order to JUnit test the toString method of public class manager

*Edited: please :code:

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>