Saturday, June 7, 2008

Review for second test...

Click here.

Wednesday, June 4, 2008

Second major assignment

I hope everyone has read up through chapter 7 in the book. Practice as many exercises as you can from the end of the chapter!

Your second major assignment is as follows:

You are going to design a class for any business of your choosing. You need to keep track of at least four pertinent attributes. You will need at least two other methods in addition to the necessary getters and setters. Create 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 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 June 15th, 2008 at midnight! Use netbeans and upload everything in a zip file to your FTP space!

DF

Nursery Program!

Today you are going to create a Plant class with the following information:

Cost

Name

Size

Quantity of plants

The nursery will create an array of plants (let's say they have 5 different types of plants).

The nursery class should keep track of:

Money taken in

Money spent on supplies

Plants on hand

The user should be able to update information about the plants and money that is coming in or out! Let's say the user should be able to update the quantity of certain plants available and the amount of money money taken in to the company!

Here's one way to loop using a trivial example:

Scanner a = new Scanner(System.in);

System.out.println("What would you like to do? [Quit] or [Deposit] $1000");

String ans = a.nextLine();

double deposit = 0;

while(!ans.equals("Quit")) //loop is going the basis

{

if(ans.equals("Deposit"))

{

deposit += 1000.0;

}

System.out.println("What would you like to do? [Quit] or [Deposit] $1000");

ans = a.nextLine();

}

System.out.println(deposit);

Find an interesting article from Slashdot.org

Write a brief summary about the article and post a link to the article on your blog!

Slashdot.org

Monday, June 2, 2008

first assignment of the day

/**
*
* @author dfreer
*/
public class NumberTester {
//Write an if statement to determine if a number is greater than fifty!
//Write the if statement within a public method to be run from a main

//if the number entered is > 50, give the user a message of congrats!!

//main to test it out!

}

Sunday, May 25, 2008

FTP access

Class, I made your FTP accounts.

The FTP service is ftp://davidcfreer.com


Username is your first name:

(Davids need to put David plus the first letter of your last name. Example: David Smith is DavidS)

Password is your MDC student ID.

If you have no idea how to use FTP, I will teach you on Wednesday before our test.

Wednesday, May 21, 2008

Major Assignment 1: Due Friday May 30th, 2008

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.

---

Turn in your source code by Tuesday, either by (A.) zipping it up and sending it to me via email (B.) zipping it up, bringing it in via flash drive and sending it to me via the MDC network (C.) http://www.megafileupload.com/ or similar and a link.


Don't forget to comment throughout your program. Refer to inputs and outputs.

If you need help, send me any questions.

DF

Email me your programs before midnight Friday May 30th, 2008 or bring it in on a flash drive on May 28th 2008.