Is there such thing as a getClass() method like the getWorld() method?
![Twitter](/assets/twitter-4e19209ef84344ee0c433f4c7bad8d49.png)
![Twitter.hover](/assets/twitter.hover-1fb19a5bafc50deace8f88eaec867845.png)
public String txtString = "";
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import java.io.*; /** * Write a description of class SaveButton here. * * @author (your name) * @version (a version number or a date) */ public class SaveButton extends Actor { /** * Act - do whatever the SaveButton wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { try{ // Create file FileWriter fstream = new FileWriter("out.txt"); BufferedWriter out = new BufferedWriter(fstream); out.write(getWorld().getStringFromObject(TxtString));<here!! //Close the output stream out.close(); }catch (Exception e){//Catch exception if any System.err.println("Error: " + e.getMessage()); } } }
out.write(((TextMaker)getWorld()).txtString);