Monday, September 29, 2008

Look at this source code:

Tic Tac Toe by a great programmer.

I'm impressed.

Wednesday, September 24, 2008

For fun and for your blog

You can read this for fun:
Now he works for Google. He's not too fond of some of his experiences at Microsoft...

_____________________________________________________

Paul Graham is a great thinker when it comes to starting new businesses. Read this article and explain why you think there aren't "more Googles."

Put your answer on your blog. You may be brief. It will count for towards your blog grade.

Second Major Assignment...also please upload your First Assignment

Please upload your first major assignment (BankAccount and LetterPrinter) to your FTP space as soon as you can. I'd rather if we kept all the assignments in the same place.

Your second major assignment is as follows:You are going to design a class for a business of your choosing. You need to keep track of at least four attributes.

You will need at least two other methods in addition to the necessary getters and setters.

After you create your class, make three objects and store them in an array of that type.

You can hard code the business testing info into the main.

But if you use Scanner to ask the user what to change, you can get 20 extra points on the assignment!

Here's an example, you will need to pick another business:

class LawFirm
{

//typeOfLaw, billableHours, nameOfLawFirm, costPerHour

//+20
//constructors
//+20
//methods: calculateTotalCost, returnMessageAboutFirm
//+30
}

class LawFirmTester
{

//create an array of 3 LawFirm objects
//+20
//display names of law firms and allow user to enter a number to learn more information about each firm
//+10
//allow the user to update the information about the firms- things do change.
//+20
}

The number of points are commented above.

Due Wednesday October 1st on your FTP space.

LoveTester

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.

Old Burgers

http://bestwellnessconsultant.com/2008/09/23/1996-mcdonalds-hamburger-karen-hanrahan-best-of-mother-earth.aspx

Wednesday, September 17, 2008

Test 1 Information

These tutorials from Sun are worth reading in addition to the book.

This developer uses these 15 exercises to master a language.

Try as many questions as you can from the Big Java book. Also read the first five chapters.

Here's a review for the first test next week.

Test 1 will be on September 23th.

Project 1 will be due on the same day. Bring in your program 1 code on a flash drive on Monday.

Coding done in class September 17th, 2008

public class HelloWorld //class designed to print hello world!
{
public static void main(String [] args)
{ //main method needed to run java application
System.out.println("Hello World!");
//syntax to print "Hello World!"
//while loop
//for loop
int counter = 0;
while(counter <= 10)
{
System.out.println(counter);
counter += 2; //the shortcut for counter = counter + 2;
}

for(int i = 100; i > 0; i --)
{
System.out.println(i);
if(i % 25 == 0){
System.out.println(i + " THIS IS A SPECIAL NUMBER!");
}

}

for(int i = 200; i > 0; i --)
{
//System.out.println(i);
if(i % 3 == 0 || i % 7 ==0 ){
System.out.println(i + " THIS IS A SPECIAL NUMBER 3 and 7");
}

}

} //Closing curly brackets /* hello */


} //closing curly brackets

1. Write a program to display "Hello World"
2. Write a program that loops to ten from 0 by 2 and prints out the result!
3. Add a for loop that counts down from 100 to 0 by one! Print out the results!
4. Within the previous loop, if a number is divisible by 25 evenly
output THIS IS A SPECIAL NUMBER!! %
5. Count down from 200 by 1 and find out if a number is divisible evenly by 3 and 7 together.
If it is print out a message "This number is divisible by 3 and 7!"
6. Start Netbeans and make a class for a student. Keep track of the GPA and Name. Provide getters,
setters, and a constructor! Call this class student.
7. Test program with main method by passing in a student
named "Jose" with a GPA of 3.5.
8. Make an array of 4 students and give them whatever info you like.
9. Print out the information in the array!
10. Ask user to enter a student name and GPA and make a student object!

Monday, September 15, 2008

If you have access...

If you purchased access to the online materials with the book publisher, here is the link to access the course.

The assignment will be due on the day of the first exam, next Monday. :)

Chapter 4 and Chapter 5 Presentations

Chapter 4




Chapter 5

Allow the user to update a vending machine

Ask a user if they want to update the stock in a vending machine. Have them continue updating either the price or quantity until they say they are ready to quit.

This will use looping, variables, user input and output, and arrays possibly.

Monday, September 8, 2008

Major Assignment 1 Due September 15, 2008

These questions are taken from the Big Java book !

Program A:
Provide a class for authoring a simple letter. In the constructor, supply the names of the sender and the recipient:

public Letter(String from, String to)

Supply a method

public void addLine(String line)

to add a line of text to the body of the letter.

Supply a method

public String getText()

that returns the entire text of the letter. The text has the form:

Dear recipient name :
blank line
first line of the body
second line of the body
. . .
last line of the body
blank line
Sincerely,
blank line
sender name

Also supply a program LetterPrinter that prints this letter.

Dear John:

I am sorry we must part.
I wish you all the best.

Sincerely,

Mary

Construct an object of the Letter class and call addLine twice.

Hints: (1) Use the concat method to form a longer string from two shorter strings. (2) The special string “\n” represents a new line. For example, the statement

body = body.concat(''Sincerely,'').concat(''\n'');

You may also use the plus sign + to add two Strings together.

adds a line containing the string “Sincerely” to the body.

Complete the following class in your solution:

/**
This class models a simple letter.
*/
public class Letter
{
/**
Constructs a letter with a given sender and recipient.
@param from the sender
@param to the recipient
*/
public Letter(String from, String to)
{
. . .
}

/**
Adds a line to the body of this letter.
*/
public void addLine(String line)
{
. . .
}

/**
Gets the text of this letter.
*/
public String getText()
{
. . .
}
private String sender;
private String recipient;
private String body;
}


Program B:
You are to create a BankAccount class with the following capabilities. The bank will be charging a fee for every deposit and withdrawal. Supply a mechanism for setting the fee and modify the deposit and withdraw methods so that the fee is levied. Test your resulting class and check that the fee is computed correctly.

The bank will allow a fixed number of free transactions (7 deposits or withdrawals) every month, and charge for transactions exceeding the free allotment. The charge is not levied immediately but at the end of the month.

Supply a new method deductMonthlyCharge to the BankAccount class that deducts the monthly charge and resets the transaction count.

Produce a test program that verifies that the fees are calculated correctly over several months.

Five bonus points if you enable user input for each program. The input will be used to create the objects.

Five more bonus points if Program B continues to loop until user chooses to Quit.

Zip up both files as Netbeans projects.

Find an article about something that interests you...

Write a very brief summary about an article that interests you.

September 8, 2008

Write a guessing game with Java where the user guesses a number between one and 100 and you give tips based on how close or far they are. If they are 20+ digits away you can laugh at them! If they are within 10-20, say they are within a decent range, otherwise say they are getting closer!

You may work with a classmate or two or by yourself.

When you are finished you may add the random number ability:

int ranNumber = (int)(Math.random()*100);

if(ranNumber > 50)
{
System.out.println(ranNumber + " is greater than 50");

}
else if(ranNumber > 25)
{
System.out.println(ranNumber + " is greater than 25");
}
else
{
System.out.println("Your number sucks!");
}

Chapter 1 and Chapter two

Chapter 1

Chapter 1


Chapter 2

Wednesday, September 3, 2008

Please give me your blog info here!

First Post: What are your expectations for the class?

Just briefly let me know what your expectations are for this class!

Client.java

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

package bankaccount;

/**
*
* @author dfreer
*/
public class Client {
//Client properties
private String firstName;
private String lastName;
private double balance;
private int socialSecurity;

//methods for the Client
public String returnName()
{
return firstName + lastName;
}
public double getBalance(){
if(balance > 0)
return balance;
else
return -9999;
}

public void deposit(double amt)
{
balance = balance + amt;
}
//this is the constructor for the client object
public Client(String fn, String ln, double b, int ss){
firstName = fn;
lastName = ln;
balance = b;
socialSecurity = ss;
}

public static void main (String [] args)
{
Client ourFirstClient = new Client("Dwyane", "Wade", 6787456.24, 123456798);
//we make an object of Client for Dwyane Wade and return his balance
System.out.println(ourFirstClient.getBalance());
//6787456.24 is expected
ourFirstClient.deposit(1000000);
System.out.println(ourFirstClient.getBalance());
//boolean a = true;
//add to the constructor an address, preferred customer capability,
//add a method to withdraw money but do not let customer withdraw more than they
//have
}

}