planty
Class Panel

java.lang.Object
  extended by planty.Panel

public class Panel
extends java.lang.Object

The UI to handle a single plant.

Author:
Nereare

Field Summary
private  int abs_day
          The absolute day of the game.
private  boolean can_harvest
          If the user can harvest yet.
private  int day
          The current day of the current month (ranges from 0 to days_by_month).
private static int days_by_month
          The number of days in each month.
private  int inventory
          The number of fruits in your possession.
private  boolean keep_on
          If the program must keep on.
private  int month
          The current month (ranges from 0 to season.length).
private  Sprouling plant
          The plant.
private  boolean plant_exists
          If there is a plant created.
private  java.util.Random rnd
          The pseudorandom number generator.
private static java.lang.String[] season
          Seasons names.
private  boolean shorty
          Whether the program should use the short version of the menu or not.
private  double talk_bonus
          When it reaches 1d, the plant's health heals by one.
private  boolean watering
          The state of watering of the plant for the day.
private  Weather weather
          The weather.
private  int year
          The current year (starts from 0).
 
Constructor Summary
Panel()
          Constructor method.
 
Method Summary
private  void cheat_KILL()
          Cheat option, avaiable only with certain key commands.
private  void cheat_MOTHERLODE()
          Cheat option, avaiable only with certain key commands.
private  void cheat_TOTAL_HEAL()
          Cheat option, avaiable only with certain key commands.
private  void check_choice()
          Checks the choice from the options menu.
private  void createPlant()
          Procedure to create a plant.
private  void echo()
          Prints an empty line in the default PrintStream.
private  void echo(java.lang.Object o)
          Prints the given content.
private  void echoErr(java.lang.Object o)
          Prints something to the default error PrintStream.
private  void exit()
          Exit (X) choice.
private  void harvest()
          Harvest crops (H) choice.
private  void inventory()
          Check inventory (I) option.
private  void loadPlant()
          Procedure to load a plant either from a list of possible precreated plants or from a file.
static void main(java.lang.String[] args)
          The execution method.
private  void medicine()
          Apply medicine (M) option.
private  void menu()
          The game's full main menu.
private  void next_day()
          Go to next day (G) option.
private  void ops()
          Error choice -when no other choice fits-.
private  java.lang.String options(int col_num)
          Formats the options to display.
private  void plantDied()
          Procedure to run when plant dies.
private  java.lang.String read()
          Executes a line-reading of the default InputStream.
private  int readInt()
          Runs the read() method and converts the input to int format.
private  void save()
          Save (S) choice.
private  void see_details()
          See plant details (S) choice.
private  void setDate()
          Sets the date variables to a new day, based only on the game's abs_day.
private  void short_menu()
          The game's short main menu.
private  java.lang.String simple_options()
          Formats the options to display with only the "hotletters".
private  void talk()
          Talk to it (T) choice.
private  void water()
          Water (W) choice.
private  boolean yes()
          Reades the default InputStream for an "yes" or "no".
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

keep_on

private boolean keep_on
If the program must keep on.


shorty

private boolean shorty
Whether the program should use the short version of the menu or not.


plant_exists

private boolean plant_exists
If there is a plant created.


can_harvest

private boolean can_harvest
If the user can harvest yet.
Fixes the multiple harvest issue.


plant

private Sprouling plant
The plant.


weather

private Weather weather
The weather.


rnd

private java.util.Random rnd
The pseudorandom number generator.


abs_day

private int abs_day
The absolute day of the game.


day

private int day
The current day of the current month (ranges from 0 to days_by_month).


month

private int month
The current month (ranges from 0 to season.length).


year

private int year
The current year (starts from 0).


days_by_month

private static final int days_by_month
The number of days in each month.

See Also:
Constant Field Values

season

private static final java.lang.String[] season
Seasons names.


inventory

private int inventory
The number of fruits in your possession.


watering

private boolean watering
The state of watering of the plant for the day.


talk_bonus

private double talk_bonus
When it reaches 1d, the plant's health heals by one.

Constructor Detail

Panel

public Panel()
Constructor method.

Method Detail

read

private java.lang.String read()
Executes a line-reading of the default InputStream.

Returns:
either the data inputed to the command-line or null in case of error.

readInt

private int readInt()
Runs the read() method and converts the input to int format.

Returns:
the user input as a integer number.

yes

private boolean yes()
Reades the default InputStream for an "yes" or "no".

Returns:
false if the user input "n", true otherwise.

echo

private void echo()
Prints an empty line in the default PrintStream.


echo

private void echo(java.lang.Object o)
Prints the given content.

Parameters:
o - something to print.

echoErr

private void echoErr(java.lang.Object o)
Prints something to the default error PrintStream.

Parameters:
o - the thing to print.

createPlant

private void createPlant()
Procedure to create a plant.


loadPlant

private void loadPlant()
Procedure to load a plant either from a list of possible precreated plants or from a file.


plantDied

private void plantDied()
Procedure to run when plant dies.


setDate

private void setDate()
Sets the date variables to a new day, based only on the game's abs_day.


options

private java.lang.String options(int col_num)
Formats the options to display.

Parameters:
col_num - number of columns of the formatation.
Returns:
these options formatted in a n columns aspect.

simple_options

private java.lang.String simple_options()
Formats the options to display with only the "hotletters".

Returns:
the "hotletters" of the options avaiable, in a single line.

check_choice

private void check_choice()
Checks the choice from the options menu.
Must be used only after calling options() or simple_options()!


menu

private void menu()
The game's full main menu.


short_menu

private void short_menu()
The game's short main menu.


see_details

private void see_details()
See plant details (S) choice.
Shows the full data for the plant and leads back the menu's short form.


next_day

private void next_day()
Go to next day (G) option.
Checks plant watering, adds a day and ages the plant.


inventory

private void inventory()
Check inventory (I) option.
Still doesn't do much.


water

private void water()
Water (W) choice.
Do the watering in the system vars and in the plant.


talk

private void talk()
Talk to it (T) choice.
There's no tip ingame, but if you talk to the plant 20 times in a day, it will heal by one.


medicine

private void medicine()
Apply medicine (M) option.
It charges 3 fruits in charge of one medicine. Each medicine heal de plant by one.


harvest

private void harvest()
Harvest crops (H) choice.
Does just the obvious... xD


save

private void save()
Save (S) choice.
Just as it sounds...


exit

private void exit()
Exit (X) choice.
Just exits the execution loop, which leads to its termination.


ops

private void ops()
Error choice -when no other choice fits-.
Just leads back to the menu, but in its short form.


cheat_KILL

private void cheat_KILL()
Cheat option, avaiable only with certain key commands.
Kills the plant instantly.


cheat_MOTHERLODE

private void cheat_MOTHERLODE()
Cheat option, avaiable only with certain key commands.
Adds 50000 fruits to the inventory.


cheat_TOTAL_HEAL

private void cheat_TOTAL_HEAL()
Cheat option, avaiable only with certain key commands.
Heals the plant back to its Perfect health.


main

public static void main(java.lang.String[] args)
The execution method.

Parameters:
args - the parameters given in the command-line call: java -jar [this file] [parameters]