Is there such thing as a getClass() method like the getWorld() method?


1 | public String txtString = "" ; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | 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()); } } } |
1 | out.write(((TextMaker)getWorld()).txtString); |