CS 21a Section B/E

Lab 2b

  1. Start with your Lab 2 (Egg Trader) submission.
  2. Arrange it so that the buyOneDozen() method does not proceed with the purchase when the egg trader does not have enough cash. (Print the message: "Not enough cash").
  3. Arrange it so that the sellEggs() method does not proceed with the sale when the egg trader does not have enough eggs. (Print the message: "Not enough eggs").
  4. Add a constructor to the EggTrader class that allows you to specify the initial cash on hand.
    (e.g., EggTrader e = new EggTrader(); starts the egg trader with 500 pesos, EggTrader e = new EggTrader( 125.00 ); starts the egg trader with 125 pesos)
  5. Create a new tester program (Call it Lab2bTester) with the code provided by your instructor.
  6. (Optional) Revise the tester so that it asks the user for input values instead (starting cash, price per dozen, number of eggs to sell, and price per egg).
  7. Zip the Blue-j folder and submit via Moodle.

Handson Exam 1

July 23 lecture

Toll lane and EPass example

Seatwork: printing shapes and letters

Shapes.zip

More exercises on printing letters

COS.zip

August 21: Programming "Contest"

Arrays

Programs defenses: August 28, 29 and Sep 1 (Room F209)
(No CS 21a classes under Vergara during those days)

Inheritance Lab

Lab6 JCreator template project ; Instructions .

Sample GUI Handson:

Specs

Calculator Frame Example:

Version 1: uses multiple listener objects, one per button
Version 2: uses a single listener object for many buttons (through ActionEvent)