Author Archives: Mr. M

The Betrothal

The Betrothal

Tom and Tammy are in love, and today’s the day that Tom is going to propose. According to custom, Tom must present Tammy with a flower as an official sign of his intentions. Tom lives in the extreme northwest corner of the island, and Tammy lives in the extreme northeast corner. The dividing river runs north and south, dividing the island roughly in the middle; the river is at least 5 cells away from the western and eastern edges of the island. The river, itself, is exactly two cells wide. Fortunately, for the lovers, there is a bridge somewhere to the south of their homes. Tom has asked Tammy to meet him at the middle of the bridge. While she suspects his motives, she doesn’t want to appear too anxious. The purpose of this program is to have Tom and Tammy find the bridge and meet in the middle where Tom will give an engagement flower to Tammy. After he has given her the flower, each returns to its home and faces the home of its betrothed. Each Jeroo starts at its home, Tom at (0,0) and Tammy at (0,23). Each can start facing any direction. Tom starts with one special flower in his pouch. A representative starting layout is shown in figure 1
Download the Island Files

Intro To Java Assignments (2013-14)

Arrays II

  • Arrays in Demo
  • Test : June 10th/11th (Arrays and two dimensional arrays)
  • Two Dimensional Arrays
  • The problem with Arrays
  • Array 2 (codingbat)  Do any 18 questions.  You can get extra credit for doing any of the last 4.  EOD Sunday  May 31st
    • All students must do sum67
  • Array Fun 2 (due by EOD Tuesday May 13rd )
  • Array Fun 1 (email to me by EOD Tuesday May 6th)

Arrays

  • short circuiting
  • Array 1 Coding Bat  type questions
  • default values of arrays
  • arrays in memory(value vs reference)
  • swapping values in an array without creating a new array like this coding bat problem–assuming you didn’t make a new array
  • Coding Bat : Array 1 (Thursday April 24th-that’s day of the 2nd class after the April break)
  • Short Circuiting

April 2nd

      • Test (April 2nd/3rd)
      • All coding bat warm up and String 1’s must be completed by then
      • Strings immutable, codingbat.com

 

 

Strings (the basics)

String Cheat Sheet



String str ="ABCDEFG"

String firstLetter = str.substring(0,1)

String firstTwoLetters = str.substring(0,2)

String lastLttr = str.substring(str.length() -1)

String last_2_lttrs = str.substring(str.length() -2 )

String middle_lttr = str.substring(str.length()/2 , str.length()/2 +1)
Unit 2

Extra credit: Looping over Strings

 

Unit I
Deadline the day you return from feb break

coding_bat_matrix


Midterm Quiz

*Wed/Thursday 21st/22nd

      • definitions:
        • pass by value
        • pass by reference
      • C++ memory usage (see last asssessment) . Yes, pretty much same questions with different numbers
      • floating point error
      • understand of whether the following data types are pass by value vs reference in Java
        • int
        • double
        • boolean

 

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)

walk-the-lake1

 

 

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

 

Scavenger Hunt and relay race

Relay Race


Download both island files.

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: 

      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.

    • 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.


Download both island files.

Bank Class

Bank Class

You have a lot of flexibility in creating this class, but here is what it should be able to do

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

 

account_with_bank_no_labels

 

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.

 

spell_T_in_python1

II.

Objective: Have a Jeroo spell out the lettter “Z ” in the same fashion as Part I

Picture of the finished project

spell_Z_in_python1

 

III.

Objective: Have a Jeroo spell out the letter “O ” in the same fashion as Part I