Monday, November 30, 2009

Using Google Sites

Using Google Sites:



Make a colorful, simple and user-friendly site. You will need to explain the following using words and code:

  1. Inheritance

  2. Interfaces

  3. ArrayList and Arrays

  4. Method overloading vs. overriding
Attach code samples to your site (zipped up Netbeans projects). Send me the URL when it is finished. If you copy other people's words, give them credit by linking to them and quoting it. Here's a site I've made.

Wednesday, November 25, 2009

Saturday, November 7, 2009

On tap for Monday...

  • Unit testing
  • Recursion (Chapter 13)

Monday, October 26, 2009

Wednesday, October 21, 2009

Monday, October 5, 2009

Today's minor project (in class)

With another person (or two, or by yourself), I would like you to create three classes for a Real Estate Business. The first will be a property class with an address, price, and area. The Residential class and Commercial class will be the subclasses of the Property class. Add two attributes to each subclass. ---Create a GUI to enter the information about the Residential or Commercial properties. Store them in an ArrayList.

Have the ability to output the ArrayList to the console.

Test Two is Monday October 12, 2009

Here is the review for the second test.

Wednesday, September 23, 2009

Presentations Chapter 7 through 10

Chapter 7



Chapter 8



Chapter 9



Chapter 10

Tell me the sum!

If we list all the natural numbers below 10 that are multiples of 3 or 5, * we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.

Wednesday, September 16, 2009

Today

Examined subString, length with Strings
Used for loops to count down
Used while loops to count up
Used do while loops to enter nonnegative numbers.
Entered three numbers and found the sum and product.
Entered three numbers and found the largest number.
Determined whether a number is a multiple of 3 or 7.
Asked user for seven numbers and stored them in an array (using a loop).
Make a String array and store 3 people's names in it. Output the results.
Use the Scanner to enter the names from the console and store them in an ArrayList.
Make a ProgrammingStudent class that stores Name, programming ability, and ID.

Wednesday, August 26, 2009

Code for method

public void determineReorder(){
if(numToys <= 3)
{
System.out.println("Reorder the toy now");
}
else
{
System.out.println("The toy is in stock with " + numToys + " left!");
}
}

Monday, August 24, 2009

Before next class...

  1. Install Netbeans and Java on your home computer.
  2. Read this tutorial about objects: http://java.sun.com/docs/books/tutorial/java/concepts/object.html
  3. Download Thinking in Java:
    http://www.odioworks.com/download/TIJ-3rd-edition4.0.zip
  4. Try to purchase the class text. It is useful.
  5. Send me an email with the following information:

    What do you hope to gain from this class?
    What experience do you have with computers?
    What is your major?
    Any pertinent information you think is necessary.

    david.freer@gmail.com

Welcome to class!

Welcome to "Introduction to Java."

My name is David Freer.

Monday, July 27, 2009

Go to betterprogrammer.com

Try this fun test. Put on your blog how you do.

Write your impressions of the site on your blog and your score if available.

See how fast you can type

Put your WPM on your blog.

Click here. Do a 1 minute test and copy and paste the results on your blog.

Test completed - here are your results:
Net Speed: 78 WPM
(words/minute)
Accuracy: 98%
Gross Speed: 79 WPM
(words/minute)
Print results

Wednesday, July 22, 2009

Project euler code!

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package projecteuler;

/**

A palindromic number reads the same both ways.
* The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.

Find the largest palindrome made from the product of two 3-digit numbers.

*/
import java.util.*;
public class palindrome {

public static void main(String [] args)
{
//discover whether a number is a palindrome...

int first3digit = 1000;
int second3digit = 1000;

boolean keepGoing = true;
int counter = 0;
ArrayList arrayList = new ArrayList();
for(int i = 1000; i > 0; i--)
{
for(int j = 1000; j > 0; j--)
{
if(isPalindrome(i*j))
arrayList.add(i*j);
}
}
int largest = arrayList.get(0);
for(int x = 0; x< arrayList.size(); x++)
{
if(arrayList.get(x) > largest)
{
largest = arrayList.get(x);
}
}
System.out.println(largest + " is the largest");
/*
while(keepGoing == true)
{
if(isPalindrome(first3digit * second3digit))
{
System.out.println(first3digit);
System.out.println(second3digit);
counter++;
}

if(counter % 2 == 1)
{
--first3digit;
}
else
{
--second3digit;
}

if(counter == 1000000000)
{
keepGoing = false;
}

if(first3digit < 0 || second3digit < 0)
{
keepGoing = false;
}


// System.out.println(first3digit);
// System.out.println(second3digit);
counter++;
}
*/

}


public static boolean isPalindrome(Integer c)
{
String a = c.toString();
boolean b = true;
for(int i = 0; i < a.length()-1; i++)
{
if(a.charAt(i) == a.charAt(a.length()-i-1))
{
//System.out.println("We've got a match!");
}
else
{
b = false;
}
}
if(b == true)
{
System.out.println("This " + a + " is a palindrome.");
return true;
}
else
{
//System.out.println("This " + a + " is not a palindrome.");
return false;
}
}
}

Extra credit

A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 99.

Find the largest palindrome made from the product of two 3-digit numbers.

Add 3 points to the final.

Searching through data

Selection sort
Insertion sort
Merge sort
Quicksort : how does it select the pivot value?
Binary search


Try to explain each algorithm in layman's terms and give the efficiency of the algorithm (Big O notation). Include a useful link if you found it.

Chapter 14

Monday, July 20, 2009

Chapter 15 and 16

Chapter 15



Chapter 16

Collections...

What is the difference between a map and a set?

Please answer on your blog...

  1. What is a stack?
  2. What is a linked list?
  3. What is a queue?
  4. How is a linked list related to an ArrayList?

Final Project

For your final project I would like you to make a program using Java. It can be a desktop or console based program.

What you choose is up to you, however, it must not be a trivial program. To ensure it is not trivial, email me your specs before Wednesday.

Due July 31st.

Final July 29th, 2009.

Wednesday, July 15, 2009

try catch

public void addTwoPlusTwo() {
int num1, num2;
try{
String text1 = jTextField1.getText();
String text2 = jTextField2.getText();
num1 = Integer.parseInt(text1);
num2 = Integer.parseInt(text2);
JOptionPane.showMessageDialog(null, num1+num2);
JOptionPane.showMessageDialog(null, "Example JOptionPane!");
}catch(Exception e)
{
JOptionPane.showMessageDialog(null, "You need numbers");
}
}

To open a new Form...

To add a new form:

Right click on your package and go to "Other".

Click on "Swing Gui Forms" and add a JFrame Form.

Then inside your button the code is:

new NewJFrame().setVisible(true);

Mario with Java

Here is a link to Mario Java source files.

Desktop application!

Write a program that teaches arithmetic to your younger brother. The program tests addition and subtraction.


In level 1 it tests only addition of numbers less than 10 whose sum is less than 10. In level 2 it tests addition of arbitrary one digit numbers. In level 3 it tests subtraction of one-digit numbers with a non-negative difference. Generate random problems and get the player input. The player gets up to two tries per problem. Advance from one level to the next when the player has achieved a score of five points.

Use a Desktop application and upload it to FreerSchools.com.

Minor project work with a partner or two or by yourself.

Here is how to make a Panel background image:

Click here and read the solution at the bottom.

Monday, July 13, 2009

Fib numbers

1, 1, 2, 3, 5, 8, 13, 21, 34, 55

try to figure out how to calculate the series without recursion...Only use loops.

Monday, July 6, 2009

try {
FileReader read = new FileReader("namesToReadIn.txt");
BufferedReader readIn = new BufferedReader(read);
String line = ""; String total = "";
while((line = readIn.readLine()) != null)
{ System.out.println(line);
total += line;
}
String [] allTheNames = total.split(",");
System.out.println("There were " + allTheNames.length + " names read in"); } catch (IOException e)
{ System.out.println(e); }

Wednesday, July 1, 2009

SCJP Training

Try this.

Minor Assignment

Create a new database and a table with two or three things.

Connect it to a Netbeans front end and show me it works. Upload it to FreerSchool.com :)

MySQL and Java

-------Next, create a database for students using MySQL and a table with some information.

CREATE TABLE address_books (first_name VARCHAR(25), last_name VARCHAR(25), phone_number VARCHAR(15), PRIMARY KEY (phone_number));

INSERT INTO address_books (first_name,last_name,phone_number) VALUES ('David','Freer','786-877-4573')";


Then create a java program (using Netbeans) and show you are able to update it and delete data from the database.

BlackJack due July 7th

I would like you to work with one or two other students on the BlackJack program.

You may make it console or GUI based.

Due July 7th on FreerSchool.com.

Have fun!

Monday, June 29, 2009

Find 5 blogs about programming/IT

google.com/reader

Describe five of the blogs you picked on your blog.

How is your progress with BlackJack?

  1. What have you done so far?
  2. What classes do you have so far?
  3. What is hard and what is easy about the process?
  4. Have you ever programmed a game before?
  5. Check out kenai.com
  6. Check out Google Code: Monopoly.

Probability

What's the probability of rolling a 2 at least twice out of three rolls?

The die has 6 sides and you'll have to show me how you figured it out. (Extra point on your next test if you show me on Wednesday.)

Wednesday, June 24, 2009

Minor Project

//Computer Inventory
//Keep track of five things. Get the info from the user (console or gui).
//Write the data about the computer inventory to a file!

Monday, June 22, 2009

Please comment on this article on your blog

Read this article and comment on your own blog. Do you agree with the author's sentiments?

Major Assignment 3 due June 28, 2009

From 10.6

Create a GUI to add workers, hours and determine their salary.

Write a superclass Worker and subclasses HourlyWorker and SalariedWorker. Every worker has a name and a salary rate. Write a method computePay(int hours) that computes the weekly pay for every worker. An hourly worker gets paid the hourly wage for the actual number of hours worked, if hours is at most 40. If the hourly worker worked more than 40 hours, the excess is paid at time and a half. The salaried worker gets paid the hourly wage for 40 hours, no matter what the actual number of hours is. Supply a test program that uses polymorphism to test these classes and methods.

Also use the following class as your tester class: /**
This class tests class Worker and its subclasses.
*/
public class WorkerTester
{
public static void main(String[] args)
{
Worker s = new SalariedWorker(''Sally'', 40);
Worker h = new HourlyWorker(''Harry'', 40);
System.out.println(s.computePay(30));
System.out.println(''Expected: 1600'');
System.out.println(h.computePay(30));
System.out.println(''Expected: 1200'');
System.out.println(s.computePay(50));
System.out.println(''Expected: 1600'');
System.out.println(h.computePay(50));
System.out.println(''Expected: 2200'');
}
}

Saturday, June 20, 2009

Solutions to second Project Euler

long* fib = new long[3];
fib[0] = 1;
fib[1] = 2;
long total = 0;
while(true) {
fib[2] = fib[0]+fib[1];
fib[0] = fib[1];
fib[1] = fib[2];
if(fib[2]>=1000000)
break;
if(fib[2]%2==0)
total+=fib[2];
}
System.out.println(total);

------

Another solution:

public class Problem2 {
public static void main(String[] args) {
int fib1 = 0;
int fib2 = 0;
int curFib = 1;
int sum = 0;
while(curFib < 1000000){
if(curFib % 2 == 0){
sum += curFib;
}
fib1 = fib2;
fib2 = curFib;
curFib = fib1 + fib2;
}
System.out.println("Solution to problem 2 = " + sum);
}
}

Wednesday, June 17, 2009

Room 2128

I'll be in room 2128 at 1pm this Saturday to review. See you there!

Monday, June 15, 2009

Real Estate GUI

With another person (or two, or by yourself), I would like you to create three classes for a Real Estate Business. The first will be a property class with an address, price, and area. The Residential class and Commercial class will be the subclasses of the Property class. Add two attributes to each subclass.
---
Create a GUI to enter the information about the Residential or Commercial properties. Store them in an ArrayList.

Have the ability to output the ArrayList to the console.

Sunday, June 14, 2009

Wednesday, June 10, 2009

Coding this weekend.

If anyone wants to review Java, I'll be available this Saturday at 1:00 pm in room 2128 at the Kendall Campus.

Hospital Project

You will be doing a "minor project" with another classmate.

We will write software using Java for a hospital to track its patients. You will first make a Patient class and four necessary methods for the Patient. Create two possible constructors for your Patient class.

Use the Patient class to create a CriticalCare patient (Remember: extends). Add an extra method that a CriticalCare patient may need to have. Create a constructor for the CriticalCare patient.

Lastly create a Hospital class that has an ArrayList of Patients and CriticalCare patients.

Use a loop to ask a user to input the information to admit a Patient and a CriticalCare patient.

Monday, June 8, 2009

Fun assignment to end the day with !

Add all the natural numbers below one thousand that are multiples of 3 or 5.

Wednesday, June 3, 2009

Major Assignment 2

There is better formatting here.





The following two programs comes from Chapter 7 in your textbook. Due Monday June 16th, 2009. Please upload both as one project and make sure to zip it before using freerschool.com.

P7.2
Implement a class Purse. A purse contains a collection of coins. For simplicity, we will only store the coin names in an ArrayList. (We will discuss a better representation in Chapter 8.) Supply a method
void addCoin(String coinName)
Add a method toString to the Purse class that prints the coins in the purse in the format
Purse[Quarter,Dime,Nickel,Dime]
Use the following class in your solution:
import java.util.ArrayList;

/**
A purse holds a collection of coins.
*/
public class Purse
{
/**
Constructs an empty purse.
*/
public Purse()
{
coins = new ArrayList();
}

/**
Adds a coin to the purse.
@param coinName the coin to add
*/
public void addCoin(String coinName)
{
. . .
}

/**
Returns a string describing the object.
@return a string in the format "Purse[coinName1,coinName2,...]"
*/
public String toString()
{
. . .
}

private ArrayList coins;
}


Use the following class as your tester class:
/**
This class tests the Purse class.
*/
public class PurseTester
{
public static void main(String[] args)
{
Purse p = new Purse();
p.addCoin("Quarter");
p.addCoin("Dime");
p.addCoin("Nickel");
p.addCoin("Dime");

System.out.println(p.toString());
System.out.println("Expected: Purse[Quarter,Dime,Nickel,Dime]");
}
}


P7.3


Write a method reverse that reverses the sequence of coins in a purse. Use the toString method of the preceding assignment to test your code. For example, if reverse is called with a purse
Purse[Quarter,Dime,Nickel,Dime]
then the purse is changed to
Purse[Dime,Nickel,Dime,Quarter]
Use the following class in your solution:
import java.util.ArrayList;

/**
A purse holds a collection of coins.
*/
public class Purse
{
/**
Constructs an empty purse.
*/
public Purse()
{
coins = new ArrayList();
}

/**
Adds a coin to the purse.
@param coinName the coin to add
*/
public void addCoin(String coinName)
{
. . .
}

/**
Returns a string describing the object.
@return a string in the format "Purse[coinName1,coinName2,...]"
*/
public String toString()
{
. . .
}

/**
Reverses the elements in the purse.
*/
public void reverse()
{
. . .
}

private ArrayList coins;
}


Use the following class as your tester class:
/**
This class tests the Purse class.
*/
public class PurseTester
{
public static void main(String[] args)
{
Purse p = new Purse();
p.addCoin("Quarter");
p.addCoin("Dime");
p.addCoin("Nickel");
p.addCoin("Dime");
System.out.println("Original purse: " + p.toString());
System.out.println("Expected: Purse[Quarter,Dime,Nickel,Dime]");
p.reverse();
System.out.println("Reversed purse: " + p.toString());
System.out.println("Expected: Purse[Dime,Nickel,Dime,Quarter]");
}
}

On your blog...

Define the following terms:

  • Interface
  • Polymorphism
  • Inner class

What are they used for? Where did you find good information about the terms?

Tuesday, June 2, 2009

Wednesday, May 20, 2009

Concepts First Java Exam June 1, 2009

Review sheet for the first java exam, June 1, 2009.

No class May 25, 2009

Due to Memorial Day, there is no class May 25, 2009.

Monday, May 18, 2009

Books online, first major assignment

For your next blog assignment, I would like you to check out this free e-book released by a college professor:

Download it here.

Direct link here.

Save it to your USB drive, I think it's a good supplemental resource! On your blog do Exercise 1.1 after reading Chapter 1.

These are the questions:

a. In computer jargon, what’s the difference between a statement and a comment?
b. What does it mean to say that a program is portable?
c. What is an executable?

Previously I asked you to read chapters 1 and 2 from Big Java. Today we covered 3-5. Follow along by reading at home.

Your first "Major Assignment" will be due in 7 days. Here it is.

Class Doctor, Class Patient

Think of four things to keep track of for a Patient

Think of three things about a Doctor to keep track of

Design 3 methods for each and a constructor for each!

Make a Patient object and a Doctor object within your main method

Work with a partner. Use if statements within two of your methods!

When you are finished, login to http://www.freerschool.com/

Your username is the first letter of your first name and your last name. Mine would be DFREER

Your password is your Miami Dade College id number.

The course id is: summerjava

When you login attach your zipped up code to http://freerschool.com/mod/forum/discuss.php?d=1

Look for the first discussion and attach your code in your reply.
---
Since moodle didn't allow discussions, please email me at david.freer@gmail.com with the zipped up Netbeans project!

Wednesday, May 13, 2009

Please review the following post on your blog

What do you think of this article? Where do you fit in?

Please comment on your own blog.

Exercise in class

With another person in class, design a Plant class for a nursery. Keep track of 5 relevant pieces of information. Then create a Nursery class and make 3 plant objects using plants found in South Florida. Output will be the three objects printed out (using toString).

Monday, May 11, 2009

Create a class blog

First assignment on blog:
http://www.blogger.com
In your own words:

What is object oriented programming?

What is a class?

What is an object?

What is a variable? Give an example.

What is a constructor?

Email me

//Name, what you expect to learn in this class, whether you
//work with computers, any other info!
//david.freer@gmail.com

At home install Netbeans 6.5 on your computer.

Welcome to COP 2800!

It's great to meet you!

Monday, April 20, 2009

Animal class and zoo class!

Create a Zoo Class and an Animal Class

Make an array of 3 zoo objects. Add 3 animal objects to each ArrayList in the Zoo. Keep track of three things about each animal.

The zoo class will have a constructor that reads in an arraylist of 3 animals. You decide what you want to keep track of with the animals.
To add a new form:

Right click on your package and go to "Other".

Click on "Swing Gui Forms" and add a JFrame Form.

Then inside your button the code is: new NewJFrame().setVisible(true);

Palindromes

A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.

Find the largest palindrome made from the product of two 3-digit numbers.

Sunday, April 19, 2009

Funniest comments...

People have encountered these comments in open source projects:

Really funny.

Wednesday, April 15, 2009

Using sites.google.com, make an Introduction to Java site

Make a colorful, simple and user-friendly site with the following information:

  1. Inheritance
  2. Interfaces
  3. ArrayList and Arrays
  4. Method overloading vs. overriding

Also attach code samples to your site. Send me the URL when it is finished. If you copy other people's words, give them credit by linking to them and quoting it.

Monday, April 13, 2009

Make "Hello World" using the Google App for Java

  1. Read the tutorial here.

Show me in class running on the localhost.

OR...

Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
Find the sum of all the even-valued terms in the sequence which do not exceed four million.

Wednesday, April 8, 2009

Awesome!

The SCJP test

I'd like you to try out this online game about the Sun Certified Java Programmer (SCJP) exam.

Evaluate it on your blog and then find three other sites to help people study for the SCJP exam and review those as well (please include URLs too!).

Go to BetterProgrammer.com

http://www.betterprogrammer.com/

Take the test and let me know how you did and what you thought of the problems using Google Documents (add me as a viewer) or on your blog.

Mario with Java!

Download this and evaluate the Creature -> Koopa OO capabilities. What sort of relationship did the developer create?

Give a summary of the classes and program on your blog.

Tuesday, April 7, 2009

Final Project

For your final project I would like you to make a program using Java.

What you choose is up to you, however, it must not be a trivial program. To ensure it is not trivial, email me your specs before April 12, 2009. If there is any problem, I will email you back.

Final project is due April 26, 2009.
Final exam is April 27, 2009.

Here are your grades so far.

FizzBuzz...

Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".

Wednesday, April 1, 2009

What do you think of this post?

Do programmers need to be "mathematically inclined"?

Write a response on your blog.

Monday, March 30, 2009

Chapter 15



Read chapter 14 and chapter 15.

Grades

View grades here.

Chapter 14

Chapter 14

Define on your blog in your own words:


  1. Algorithm
  2. Selection sort
  3. Big O notation
  4. Insertion sort
  5. Merge sort

Look over the code but focus on concepts not coding.

Wednesday, March 25, 2009

Can anyone make sense of the recursive algorithm?

I was working on this problem:

A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or alphabetically, we call it lexicographic order. The lexicographic permutations of 0, 1 and 2 are:

012 021 102 120 201 210

What is the millionth lexicographic permutation of the digits 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9?

and I found this page:

http://www.cut-the-knot.org/do_you_know/AllPerm.shtml

"Recursive algorithm

The recursive algorithm is short and mysterious. It's executed with a call visit(0). Global variable level is initialized to -1 whereas every entry of the array Value is initialized to 0.

void visit(int k)
{
level = level+1; Value[k] = level; // = is assignment

if (level == N) // == is comparison
AddItem(); // to the list box
else
for (int i = 0; i < N; i++)
if (Value[i] == 0)
visit(i);

level = level-1; Value[k] = 0;
}

"

Can anyone make sense of this?

DF
new wordsIveLearned(nameNew).setVisible(true);

Monday, March 23, 2009

Major Assignment 5 Due 4/5/09 on FTP

Instructions for Major Assignment 5 due 4/5/09.


Make this simpler?

/* * To change this template, choose Tools Templates * and open the template in the editor. */
package recursion;
/** * * @author dfreer */
public class Main {
public static void countDown(int x) {

//make a recursive method that counts down from itself until 0 and
//also prints out each number...go down by one!!
if(x == 0)
{

}
else
{
System.out.println(x);
countDown(x-1);
}
}

public static int calcMinimum(int [] a, int counter, int minimum)
{
if(counter == a.length-1)
{
if(a[a.length-1] < minimum)
{
return a[a.length-1];
}
else
return minimum;
}
else
{
if(a[counter] < minimum)
{
minimum = a[counter];
System.out.println("We got here!");
return calcMinimum(a, ++counter, minimum);
}
return calcMinimum(a, ++counter, minimum);
}
}

public static void main(String[] args) { // TODO code application logic here
int [] b = {7,16,23,-55}; //expecting -55
System.out.println(calcMinimum(b,0,b[0]));
//countDown(10);
//start counter at 0 and minimum at 0 }}

Wednesday, March 18, 2009

CarCustomers Minor Project

Today you are going to make a GUI application to keep track of the Name, Phone, Address, and whether a user has made a previous purchase before.

You can use a 3 Strings and a boolean.

Add the information to an ArrayList.

Have a button that will show the information that user has entered.

Four people finished it in class. Everyone else should upload it to their FTP space before March 25, 2009.

I will be in the computer lab (6103) at 2:30 on Friday to help people with this!

Hope to see you there.

Grades by id

View grades here.

Monday, March 16, 2009

Love Tester Minor Project *In class*

Using a Java GUI evaluate three pieces of information from Person A and three pieces of information from Person B.

Determine if they are a good match and output it to the GUI!

It doesn't have to be serious.

Minor project grade. Work with someone from class if you wish.

Due By March 23rd, 2009 on FTP.

What do you think of BlueJ?

Is it a good tool for teaching Java?

When you finish, try dling this:

http://www.davidcfreer.com/auction.zip

Try it out in BlueJ!

Please write a response on your blog...

http://moishelettvin.blogspot.com/2006/11/windows-shutdown-crapfest.html

Wednesday, March 4, 2009

MySQL and Netbeans

Download MySQL here.


CREATE TABLE address_books (first_name VARCHAR(25), last_name VARCHAR(25), phone_number VARCHAR(15), PRIMARY KEY (phone_number));

INSERT INTO address_books (first_name,last_name,phone_number) VALUES ('David','Freer','786-877-4573')";

-------Next, create a database for students using MySQL and a table with some information.

Then create a java program (using Netbeans) and show you are able to update it and delete data from the database.

Work with another classmate and upload it to your FTP space. However, when you finish call me over and I'll grade it in class.If you need numbers, you can use INT this.

Monday, March 2, 2009

Almost done grading the third major assignments...

For the next project please put your name in the comments of your classes. It will make grading it easier. I'll finish grading the third assignments tonight.

Your next project is due March 15, 2008.

It comes from Chapter 12 in the book.

Write a summary of (1) writing to a file and (2) read files with Java.

Write a brief post that describes how to write to a file and how to read in a file using Java.

Monday, February 23, 2009

Create a GUI that takes in input and gives it back in a text area

Think of a creative use for a GUI. Have the user give some information in, save it in some variables, and output it back to the user in a text area.

Zip it up and put it on your FTP space.

Funny

http://rymden.nu/exceptions.html

Friday, February 20, 2009

Wednesday, February 18, 2009

Major Assignment 3 Due

Exercise P10.5
Make a class Employee with a name and salary. Make a class Manager inherit from Employee. Add an instance field, named department, of type String. Supply a method toString that prints the manager's name, department, and salary. Make a class Executive inherit from Manager. Supply appropriate toString methods for all classes. Supply a test program that tests these classes and methods.

Use the following class as your tester class:
/**
This program tests the Employee class and its subclasses.
*/
public class EmployeeTester
{
public static void main(String[] args)
{
Employee e = new Employee(''Edgar'', 65000);
Manager m = new Manager(''Mary'', 85000, ''Engineering'');
Executive v = new Executive(''Veronica'', 105000, ''Engineering'');
System.out.println(e);
System.out.println(''Expected: Employee[name=Edgar,salary=65000.0]'');
System.out.println(m);
System.out.println(''Expected: Manager[super=Employee[
name=Mary,salary=85000.0],department=Engineering]'');
System.out.println(v);
System.out.println(''Expected: Executive[super=Manager[
super=Employee[name=Veronica,salary=105000.0],
department=Engineering]]'');
}
}

Exercise P10.6
Write a superclass Worker and subclasses HourlyWorker and SalariedWorker. Every worker has a name and a salary rate. Write a method computePay(int hours) that computes the weekly pay for every worker. An hourly worker gets paid the hourly wage for the actual number of hours worked, if hours is at most 40. If the hourly worker worked more than 40 hours, the excess is paid at time and a half. The salaried worker gets paid the hourly wage for 40 hours, no matter what the actual number of hours is. Supply a test program that uses polymorphism to test these classes and methods.

Use the following class as your tester class:
/**
This class tests class Worker and its subclasses.
*/
public class WorkerTester
{
public static void main(String[] args)
{
Worker s = new SalariedWorker(''Sally'', 40);
Worker h = new HourlyWorker(''Harry'', 40);
System.out.println(s.computePay(30));
System.out.println(''Expected: 1600'');
System.out.println(h.computePay(30));
System.out.println(''Expected: 1200'');
System.out.println(s.computePay(50));
System.out.println(''Expected: 1600'');
System.out.println(h.computePay(50));
System.out.println(''Expected: 2200'');
}
}
Due February 27, 2009

Monday, February 16, 2009

Read this article...

Blog Assignment:
Read this article.
  1. On your article, explain what the article is about in less than a paragraph.
  2. Do you agree with the author?

Thursday, February 12, 2009

Test 2 Review online

Look to the right. See you Monday. Study Chapter 7, 9, and 10.

DF

Wednesday, February 11, 2009

Today in class...

You will be doing a "minor project" with another classmate.

We will write software using Java for a hospital to track its patients. You will first make a Patient class and four necessary methods for the Patient. Create two possible constructors for your Patient class.

Use the Patient class to create a CriticalCare patient (Remember: extends). Add an extra method that a CriticalCare patient may need to have. Create a constructor for the CriticalCare patient.

Lastly create a Hospital class that has an ArrayList of Patients and CriticalCare patients.

Use a loop to ask a user to input the information to admit a Patient and a CriticalCare patient.

Please upload it to your FTP space as Hospital.zip.

DF

Monday, February 9, 2009

Define: Protected, super, and extends

On your blog define protected, super and extends.

Presentations

Chapter 9



Chapter 10

Friday, February 6, 2009

Second Major Assignment due February 16th







The following two programs comes from Chapter 7 in your textbook. Due Monday February 16th, 2009. Please upload both as one project and make sure to zip it before using FTP.

P7.2
Implement a class Purse. A purse contains a collection of coins. For simplicity, we will only store the coin names in an ArrayList. (We will discuss a better representation in Chapter 8.) Supply a method
void addCoin(String coinName)
Add a method toString to the Purse class that prints the coins in the purse in the format
Purse[Quarter,Dime,Nickel,Dime]
Use the following class in your solution:
import java.util.ArrayList;

/**
A purse holds a collection of coins.
*/
public class Purse
{
/**
Constructs an empty purse.
*/
public Purse()
{
coins = new ArrayList();
}

/**
Adds a coin to the purse.
@param coinName the coin to add
*/
public void addCoin(String coinName)
{
. . .
}

/**
Returns a string describing the object.
@return a string in the format "Purse[coinName1,coinName2,...]"
*/
public String toString()
{
. . .
}

private ArrayList coins;
}

Use the following class as your tester class:
/**
This class tests the Purse class.
*/
public class PurseTester
{
public static void main(String[] args)
{
Purse p = new Purse();
p.addCoin("Quarter");
p.addCoin("Dime");
p.addCoin("Nickel");
p.addCoin("Dime");

System.out.println(p.toString());
System.out.println("Expected: Purse[Quarter,Dime,Nickel,Dime]");
}
}

P7.3


Write a method reverse that reverses the sequence of coins in a purse. Use the toString method of the preceding assignment to test your code. For example, if reverse is called with a purse
Purse[Quarter,Dime,Nickel,Dime]
then the purse is changed to
Purse[Dime,Nickel,Dime,Quarter]
Use the following class in your solution:
import java.util.ArrayList;

/**
A purse holds a collection of coins.
*/
public class Purse
{
/**
Constructs an empty purse.
*/
public Purse()
{
coins = new ArrayList();
}

/**
Adds a coin to the purse.
@param coinName the coin to add
*/
public void addCoin(String coinName)
{
. . .
}

/**
Returns a string describing the object.
@return a string in the format "Purse[coinName1,coinName2,...]"
*/
public String toString()
{
. . .
}

/**
Reverses the elements in the purse.
*/
public void reverse()
{
. . .
}

private ArrayList coins;
}

Use the following class as your tester class:
/**
This class tests the Purse class.
*/
public class PurseTester
{
public static void main(String[] args)
{
Purse p = new Purse();
p.addCoin("Quarter");
p.addCoin("Dime");
p.addCoin("Nickel");
p.addCoin("Dime");
System.out.println("Original purse: " + p.toString());
System.out.println("Expected: Purse[Quarter,Dime,Nickel,Dime]");
p.reverse();
System.out.println("Reversed purse: " + p.toString());
System.out.println("Expected: Purse[Dime,Nickel,Dime,Quarter]");
}
}

Wednesday, February 4, 2009

Definitions

On your blog define and provide code examples (syntax) for the following terms:

  • Overloading
  • Interface
  • Polymorphism

Wednesday, January 28, 2009

Graded the first major assignment

There were some awesome Bank Account programs. Very nice. The average grade for everyone was 89.7. I left a txt file on your FTP space with some comments and a grade.

I changed the test to next Monday on the syllabus. I will have a review sheet online today as well.

See you in class!

Monday, January 26, 2009

Chapter 4


Chapter 5


Chapter 6


Chapter 7

Thursday, January 22, 2009

Here's a sample main method to test your Bank Account:

public static void main(String[] args)
{
BankAccount account1 = new BankAccount();
account1.deposit(100);
System.out.println(account1.getTransactionCount());
System.out.println("Expected: 1");
BankAccount account2 = new BankAccount(1000);
account2.withdraw(100);
System.out.println(account2.getTransactionCount());
System.out.println("Expected: 1");
BankAccount account3 = new BankAccount();
account3.deposit(1000);
account3.withdraw(100);
account3.deposit(1000);
account3.withdraw(100);
account3.withdraw(100);
System.out.println(account3.getTransactionCount());
System.out.println("Expected: 5");
}

Wednesday, January 21, 2009

Study session

I'm very excited about the beginning of the term. I will be in the computer lab

(Study Center in Room 9103)

tomorrow at 4:30 pm and Friday at 3:30 pm to help you with your code for your first two projects.

If you are interested in coming either day, email me so I can have an idea of how many students will be there. If it's too many, perhaps we can stagger the times.

FTP Login

Use your first name with a capital letter:

Example:

John

Password:
MDC ID

DavidB is the only student who needs to use their last initial. I have the David account. :)

Fernando Rivero will login as FernandoR

Monday, January 19, 2009

Major Assignments Summer 2009

Here's your first assignment.

Here's your second assignment (due June 16th, 2009).

Here's your third assignment.

Here's your fourth assignment. (Due July 7th, 2009).

Wednesday, January 14, 2009

NumberGuesser

Ask the user for a number. If the user's number is yours (you picked it earlier!) thank the user for playing. Otherwise tell the user if the number they guessed is higher or lower than the number you have picked!

Create a Java program to give you acceptable age ranges

Take your age divide by two and add seven...this is the upper and lower bound of the ages you can date.

http://www.xkcd.com/314/

Here's one solution:

int myAge = 20;
double acceptableRange = (myAge/2)+7;
// System.out.println(acceptableRange);
double difference = myAge - acceptableRange;
// System.out.println(difference + " is the difference");
System.out.println("You are " + myAge + " years old");
System.out.println("The oldest you can date is "+ (myAge + difference));
System.out.println("The youngest you can date is " + acceptableRange);

Lemonade Stand!

What classes will you need for a Java program representing a Lemonade Stand?

What attributes will each class need?

What methods will each class need?

Please write it on your blog as follows:

Class A
Attributes

Methods

Class B
Attributes

Methods

So on...

Monday, January 12, 2009

Once you get everything installed...

Try to create a program that will calculate the area of a rectangle given the length and width. Not for a grade, just to try it.

First post!!!

  1. Describe the difference between a class and object in Java.
  2. What is a method?
  3. What is a variable?


When you are finished, add your information here:

Wednesday, January 7, 2009

Welcome to class!

Notice the links to the right of this post. There will find the syllabus, class notes, a great review about classes and objects, an installation guide, a reference guide and many other great links.

Also check out previous posts from other semesters. It may help you get an idea for what we'll do in this class. Of course, each class is different.

I am very excited about this course.

Things to do:
  • Install Netbeans and Java ASAP.
  • Get the book and read the first two chapters.