Objective: Your goal is get your jeroo onto the right side of the island. Note that the red areas are nets. You must toss() a flower onto the net before you can go on the net.. You will need the following island file .
Monthly Archives: December 2013
Walk-the-lake
Monsoon rains have created a lake in the middle of Santong Island. Furthermore, that lake contains an island. Two Jeroos were separated by the rains. One is on the main part of Santong Island, but the other is on the island in the middle of the lake. The goal of this program is to have each Jeroo explore the shoreline of the lake.
- Each Jeroo starts with one flower and the lake immediately to its right.
- Each Jeroo starts by planting a flower then traveling, keeping the lake on its right, until it returns to the flower. The Jeroo then picks the flower.
- (only plant 1 flower, at starting point…and make 1 lap until you are back at that flower)
- Have the Jeroo on the main part of Santong Island walk the shore first.
- then have the one on the lake’s island walk the shore
Download Walk the Lake (This has several maps, choose any 1)
Acknowledgement
This problem is adapted from one that was created originally by Erica Eddy of The University of Wisconsin – Parkside.
Or you can try walk the lake using loops using this map and Jeroo assignment
Jeroo Custom Methods
Do you ever wish that you could make your Jeroo turn around 180 degrees?
Example 2 of a Custom Method to “Go Around a net”
You can download the files for the animation below here
Scavenger Hunt and relay race
Relay Race
Objective: Three Jeroos (you give them names) are practicing for the Santong Relays. Figure 5 shows the course at the start of the race. The first Jeroo begins at (4,9) facing EAST. It must pick the flower and give it to the second Jeroo who begins at (7,13) facing NORTH. The second gives the flower to the third Jeroo who begins at (4,15) facing WEST. The third Jeroo must plant the flower at (3,16), run to (3,21) and stop
Scavenger Hunt
Objective:
- The Jeroos can only turn LEFT
- The Jeroos must take turns, each doing only thing in each turn: hop(), turn(LEFT), or pick()
- A Jeroo can only hop forward one space in its turn.
- Two Jeroos start at opposite ends of Long Island, one at (3,5) facing EAST, and one at (5,18) facing WEST. Each Jeroo is supposed to pick two flowers. The first one can be from anywhere along the edge of the island, and the second must be the one in the center. The first one to pick the center flower is declared the winner. There are a few rules to this scavenger hunt.
Beautify The Island
Objective: Your goal is to have a jeroo beautify the Island. Instantiate a jeroo with 8 flowers in its pouch and have the jeroo plant the flowers in the pattern below Download these beginning-activites
Bank Class
Bank Class
You have a lot of flexibility in creating this class, but here is what it should be able to do
- manage an array list of Accounts that could be any kind of account private ArrayList<Account>
Functionality that you *must* implement.
It’s up to you to decide how to implement the functionality below. You will only lose credit if your methods clearly make no sense, have bad variable names/method names.
- add an Account (of any type)
- remove an account by
- account id
- owner (a Person object)
The functionality above ^^ can be implemented in any efficient way that makes sense, but it must be implemented. I am leaving that part up to you!
- Some Specific Required Methods
-
public ArrayList<Person> topAccountOwners(double cutoff)
- this method returns an ArrayList of the owners whose accounts have at least cutoff amount of balance
-
public void nightlyUpdate()
- this runs through the accounts and if account is a SavingsAccount , then it calls that object’s recordDailyBalance() method (You are going to have to use instanceOf and then cast those accounts to a SavingsAccount )
- public Account topBalance() ; returns the Account object with the greatest balance
- public Account[] allWithinRange(double min, double max) returns an array of Accounts whose balances range from min to max , inclusive
- public boolean transfer( double amount, int accountIdFrom , int accountIdTo) ; this method transfers money from the one account to the other. If the accountIdFrom does not have enough $$, this method returns false.
-
public void monthlyUpdate()
- this runs through the accounts and if
- account is a SavingsAccount , then it calls that object’s updateInterestPayment() method
-
** extra credit ArrayList<Account> sortByAmount()
- this method returns an arraylist of Accounts sorted by amount in the account
-
public ArrayList<Person> topAccountOwners(double cutoff)
Jeroo Spelling Letters (python)
I. Copy and paste this code below in the Jeroo “IDE”. Run the code several times unti you understand what is going on, then try experimenting with the code, changing it around until you are comfortable with the basic methods of a Jeroo.
II.
Objective: Have a Jeroo spell out the lettter “Z ” in the same fashion as Part I
Picture of the finished project
III.
Objective: Have a Jeroo spell out the letter “O ” in the same fashion as Part I
Jeroo Methods 1 (Python)
Account Abstract Class Assignment
This is the first part of a 2 part project.
Person Class
Constructor
- public Person( String _name , int _age )
instance Variables
- private String name
- private int age
Methods
- public String getName()
- public int compareTo(Person other) { return this.age - other.age; }
Account – Abstract Super Class
Static Variable(s)
- private static int nextAccountNum
- private static int parentCompanyCode = 12810 ;
instance Variables
- private int accountNumber// first account number should be 1
- protected double balance
- protected ArrayList<Person> owners
Constructor
- public Account( double _balance, Person _owner) // add _owner to ArrayList owners
Methods
- public static int getParentCode()
- public int getAccountNumber()
- public void deposit(double amount)
- public double getCurrentBalance()
- public abstract boolean withdraw(double amount)
- public boolean equals(Account other) // are the unique account numbers equals ?
- public String toString() Output should follow the conventions we have discussed. I will be testing for formatting like this :
- public int comparesTo(Account other) { return this.accountNumber- other.accountNumber } (Note that this method has an ‘s‘ )
- public void addOwner(Person p) //adds P to the ArrayList of owners
- public ArrayList<Person> getOwners() // returns the ArrayList of owners
- public Person remove( Person p) // this emulates the ArrayList’s remove() method (link) . Remember that that method removes the object and then returns the removed object. In this case, you should remove Person P from the ArrayList of owners
- CheckingAccount extends Account
- This class has to do certain things. You can decide the best way to do it. This class should have a way to
- attempt to withdraw money by writing a check. Every check should have a ‘check number’, which should be an integer. The lowest permissible value for a check number is 100 .
- public int writeCheck(double amount) // @ returns the check number of the written check
-
public boolean cancelCheck(int checkNumber)
- be able to cancel checks and keep track of the check numbers that have been cancelled
- when a check is cancelled, the amount associated with that check is added back onto the balance.
- return true if checkNumber is a valid check number; false otherwise.
- One solution
- every time you write a check, you need a new check “#”
- writeCheck( double amount) - > tries to call this.withdraw(double amount) . You can then use ArrayLists to store check numbers, associated check amounts , things like that
SavingsAccount extends Account
- instance variables
- private double interestRate // //@ assumes that interest rate is not in decimal format i.e. 1.7 not .017
- private ArrayList<Double> dailyBalances
static variables
- public static final int MINIMUM_BALANCE=100; // this is the absolute minimum amount of money that must always be in the account
- methods
- public boolean withdraw(double amount) //@override the withdraw() method to ensure that currentBalance the never gets below MINIMUM_BALANCE
- public void updateInterestRate(double newRate) //updates the interestRate
- public void recordDailyBalance() // @ record current day’s balance by storing current balance in dailyBalances .
- public ArrayList<Double> getDailyBalances() // @ return dailyBalances .
- public double projectBalance(double timeInYears) // use the compound interest formula . Assume that the bank compounds the balance monthly. To learn more about how compound interest really works, click here .
- You will need to convert interest rate from something like 1.7%, as an example , to 0.017
- public void updateInterestPayment() // @ once a month update account based on average daily balances and interest rate.
*calculate the average monthly balance
* multiply balance by the interest rate (remember this must be converted to decimal)
* add that interest back onto the balance
CertificateOfDeposit extends SavingsAccount
instance Variables
- public static final double EARLY_WITHDRAW_PENALTY= 200 .
Methods
- public boolean withdraw(double amount , boolean isEarly ) //@override the withdraw() and applies penalty to balance
Tester file :
When you are done, you can begin the Bank project .
The Case for Abstract Classes and Methods
Shape
Constructor
- public Shape( int _col)
instance Variables
- protected int color
Accesor Methods
- public abstract double getArea(); //returns the area of the triangle
- public int getColor()
- public void render() { System.out.println(“rendering shape” ) ; }
Now, let’s refactor our class relationships to represent our new Iheritance Tree
- refactor all subclasses to reflect new class hierarchy
- Update our new InteractiveMath class –InteractiveMath3