package de.dhbwstuttgart.strucTypes;

import java.util.ArrayList;
import java.util.List;

import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.FormalParameter;
import de.dhbwstuttgart.syntaxtree.Method;

public class TV_Method extends TV_Abstract {	
	
	ClassOrInterface cl; 
	Method method;
	
	List<TV_Alpha> alpha_strich;
	TV_Gamma tv_gamma; 
		
	public TV_Method(ClassOrInterface cl, Method method ) {
		super(); 
		this.cl = cl; 
		this.method = method; 	
		
		// Typvariablen Parameter
		this.alpha_strich = new ArrayList<TV_Alpha>(); 

		
		for (int i = 0; i < method.getParameterList().getFormalparalist().size(); i++  ) {
			FormalParameter fp = method.getParameterList().getFormalparalist().get(i); 			
			TV_Alpha tv_alpha = new TV_Alpha(method, i , cl, fp); 
			this.alpha_strich.add(tv_alpha); 
		}		
		
		
		// Returntyp 
		this.tv_gamma = new TV_Gamma(method, cl); 			
	}
	
	
	public String toString() {	
		
		String typvarpar = ""; 
		for (TV_Alpha tv : this.alpha_strich  ) {
			typvarpar =   typvarpar + tv.toString(); 
		}
		// TODO : Ausgabe Return type
		// Ausgabe TV_Method(  parametertypevar -> returntype)  
		return String.format("(  %s -> %s   )"  , typvarpar, this.tv_gamma.toString() );  
	}
	
	
	
	
	
	
	

}
