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

Implicit super constructor ** is undefined. Must explicitly invoke...

$
0
0
Implicit super constructor Worker() is undefined. Must explicitly invoke another constructor

Here is the code that i'm getting this message on. Yes it is for a school assignment. There are 3 classes, Worker, Producer, and Manager. I'm stuck with this error on both of the sub classes(Producer and Manager).

//Worker class


public class Worker{

	String n;
	static long uW;
	
	public static void main(String[] args)
	{
		//producer producerObject = new Producer();
	}
	
	public Worker(String name, long unitsWorked)
	{
		n = name;
		uW = unitsWorked;
	}
	
	public long work(long units)
	{
		//long unitsWorked = 0;
		long worked = 0;
		if (units>=1)
		{
			uW = (units + worked);
			return uW;
		}
		else 
			return uW;
	}
	
	
	public long getUnitsWorked()
	{
		//double unitsWorked;
		return uW;
		//System.out.println(uW);
	}
	
	public double pay(double multiplier)
	{
		double mult = multiplier;
		double paid = mult*uW;
		uW = 0;
		return paid;
	}
	
	public String toString()
	{
		String s = super.toString();
		return "name: " + n + "units worked: " + uW;
	}
}



//Producer class


public class Producer extends Worker{
	
	private int proTar;
	long uW = Worker.uW;
	String n;
	
	public static void main(String[]) args)
	{
		
	}
	
	public Producer (String name, int productionTarget)
	{
		proTar = productionTarget;
		n = name;
	}
	
	public long work(long units)///////////////////////doesn't quite make sense at the moment, need to go over directions, probably for all 3 classes
	{
		//long unitsWorked = 0;
		long worked = 0;
		if (units>=1)
		{
			uW = (long) (units * .5 * proTar);
			return uW;
		}
		else 
			return uW;
	}
	
	public int getProductionTarget()
	{
		//double productionTarget; 
		return proTar;
	}
	
	public double pay(double multiplier)
	{
		double mult = multiplier;
		double paid = mult*uW;
		Worker.uW = 0;
		return paid;
	}
	
	public String toString()
	{
		String s = super.toString();
		return super.toString() + " name: " + n + ", Units Worked: " + uW + "," +
		" Production Target: " + proTar ;
	}

}



//Manager Class


public class Manager extends Producer{
	
	
	int nS;
	int units = 0;
	boolean wl;
	long uW = Worker.uW;
	String n;
	
	
	
	public Manager(String name, int numberSubordinates, boolean wellLiked)
	{
		nS = numberSubordinates;
		n = name;
		wl = wellLiked;
	}
	
	public long work(long units)//if the parameter recieved is less then or equal to 0 return nothing
	{
		//long unitsWorked = 0;
		long worked = 0;
		if (units>=1)
		{
			uW = (long) (units * .75 * nS );
			return uW;
		}
		else 
			return uW;
	}
	
	public double pay(double multiplier)
	{
		double mult = multiplier;
		double paid = mult*Worker.uW;
		Worker.uW = 0;
		return paid;
	}

	public String toString()
	{
		String s = super.toString();
		return super.toString() + " name: " + n + ", unitsEarned: " + uW + "," +
				" numberSubordinates: " + nS + ", wellLiked: " + wl;
	}
}



The manager has to extend the producer which extends worker. I'm guessing i'm going about it in a less then perfect sort of way.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



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