For Those who asked I post New Java Progams - Honda Motorcycles - FireBlades.org
Off-Topic Discussion of anything that doesn't fit anywhere else. If it's related to motorcycles in any way, DO NOT post it here. Post it in General Discussion or a more specific forum.

User Tag List

 
LinkBack Thread Tools
post #1 of 7 Old 07-03-2003, 9:40 AM Thread Starter
Jay
 
Join Date: 05-11-2003
Posts: 1,119
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Reputation Power: 0
 
Re: For Those who asked I post New Java Progams

Quote Just got the Project, Its kinda lengthly. I will add to the post more stuff needed, meanwhile this is the Requirements and should be enough for the 'bored' to try if they want.


OOP Food Project
Scope
Design and develop a set of seven classes in Java that incorporate the menu items for a restaurant.

Objective
Apply the OOP concepts that we leaned in class and read in the textbook.

Value
This project is worth 225 points.

Due Date
This project is due 10 PM, Tuesday, July 8, via Blackboard's Digital Dropbox.

Complete the IAm.java program, downloadable from BlackBoard.

Testing
This project is automatically graded via the TasteTester.java program. It grades 200 points of the 225 total points.

Program FoodList.java populates several instances of Food objects (from the FoodDBMS.java program) and displays them in a window. These two programs should run un-modified. It is used for testing to display objects of your Food classes.

Program Opinion.java displays your IAm class in another window and is called by FoodList.

Project Grading Guidelines
Grading Guidelines
Points

TasteTester
200

Adherence to Good Programming Practices
25

Total
225


Appropriate points are taken off for projects under the following conditions:

They are late

They fail to compile

TasteTester
TasteTester runs 50 tests on your food classes, worth 4 points each for 200 points.

This program will act as a 'consumer' of your food classes, by creating instances of them and running various tests to see if they are acting as designed. Include this program (and the other programs that came with the project) in your project. Develop your seven food classes according to the requirements listed below. Compile errors in the TasteTester.java program are caused by problems in your code--probably a missing class, method of a class, parameters to a method, or the order or type of parameters to a method. Read the compiler error message in TasteTester, then correct the error in YOUR program. You should NEVER change the code in the TasteTester program. If you feel that the TasteTester program is in error, then notify the instructor.

Good Programming Practices
This is a 'sniff' test by the instructor to ensure that you are using proper programming practices.

The student has designed a solid Object-Oriented Program design incorporating super classes, sub-classes, abstract & concrete classes and methods, and the appropriate private, protected, and public properties and methods.

The code should compile cleanly and should serve its stated purposes. The included FoodDBMS.java program should create your various food objects by calling your constructor and other methods. The FoodList.java program should display the food items, providing the correct values.

The textbook presents numerous Good Programming Practices throughout the discussions, and a summary at the end of each chapter. Follow the letter and intent of these practices in designing and creating well-written Java applications. There is little to no duplicate code and no non-executable code.



In addition, appropriate commands, classes, and methods are incorporated appropriately throughout the application.

The student has designed a logical and well-constructed program.

The program source code is easy to follow and maintain. Names are meaningful and consistent. Variables and classes are used appropriately. The code is well documented, formatted with proper indentation and alignment. White space is used appropriately. There is no extraneous code (code that serves no purpose). Programs are written efficiently and blend performance with size.



A print out of the code would be easy to follow. Use consistent and proper indentation and use of white space.

Be consistent! Be proud of your work!

Program Requirements
Create seven classes, based on the following URL diagram.


Food
- String name

- float price

- int calories

+ float static final TAX
(default tax rate is 4.5%)

+ float static final TIP
Suggested TIP rate is 15%


+ Food( String name, float price, int calories )

+ String getName( )

+ void setName( String name )

+ int getCalories( )

+ void setCalories( int calories )
Calories should be a non-negative number. If negative, set it to 0.

+ float getPrice( )

+ void setPrice( float price )
Price should be a non-negative number. If price is negative, set it to 0.00.

+ float getTip( )
Returns the suggested amount of the tip, based on the price.

+ String toString( )
Returns the name of the Food item.

+ float getTax( )
Returns the tax amount.

+ String getDesc( )
Returns the values for the special properties for each Food object. Do not include periods ( . ) in your descriptions.



Drink extends Food
- String servingTemp
One of: ROOM_TEMPERATURE, COLD, HOT

- String container
Such as 'Glass', 'Cup', 'Can'

- boolean regulated
True if Drink is regulated

- String[] temperatures
'Room Temperature', 'Cold', 'Hot'

+ int static final ROOM_TEMPERATURE
0

+ int static final COLD
1

+ int static final HOT
2


+ Drink( String name )
Defaults: serving temperature is COLD; container is 'Glass'

+ Drink( String name, int servingTemp, String container )
Default regulated is false

+ Drink( String name, int servingTemp, String container, float price, int calories, boolean regulated)

+ void setServingTemperature(int servingTemp)
Validate for serving temperature constant. If invalid, set serving temperature to Room Temperature.

+ String getServingTemperature()
Return the String representation of the serving temperature

+ void setContainer(String container)

+ String getContainer()

+ void setRegulated( boolean regulated )
true: indicates that this drink is regulated.
false: indicates that the drink is not regulated.

+ boolean getRegulated()

+ float getTax( )
Returns the default tax amount, however, there is an additional 1% tax on regulated Drinks.

+ String getDesc( )
Returns the values for serving temperature, container, and regulated status.



Appetizer extends Food
- int numberOfPeople
The number of people this appetizer is intended to serve


+ Appetizer( String name, int people )
Defaults: price is 0; calories is 0

+ Appetizer( String name, int people, float price, int calories


+ void setNumberPeople(int people)
Validate for numbers between 1 and 4 (inclusive). If invalid, set the number of people served to 1.

+ int getNumberPeople()


+ getTax( )
returns the default tax amount.

+ String getDesc( )
Returns the values for number of people served.



Entree extends Food
- String ethnic
The ethnicity of the entree, e.g., 'Mexican', 'Chinese', 'Italian', etc.

- boolean onPremise
true: Indicates that the entree is consumed on the premises.
false indicates that the food is a carry-out.


+ Entree(String name, String ethnic, float price, int calories, boolean onPremise )


+ void setEthnic(String ethnic)


+ String getEthnic()


+ void setOnPremise( boolean onPremise )


+ boolean getOnPremise()


+ getTax( )
The default tax amount, plus .5%, plus an additional 1% for entrees consumed on the premises.

+ String getDesc( )
Returns the values for ethnic and on premise status.



Meat extends Entree
- String meatType
e.g. Beef, pork, poultry, etc.

- int cookedStyle
One of the following cookedStyle values:

+ int static final RARE
0

+ int static final MEDIUM_RARE
1

+ int static final MEDIUM
2

+ int static final MEDIUM_WELL
3

+ int static final WELL
4


+ Meat(String name)
Default ethnic to 'Unknown', type to 'Mystery', cooked style to MEDIUM, price to 0, calories to 0, and onPremise to True

+ Meat(String name, String ethnic, String type, int cookedStyle, float price, int calories, boolean onPremise)


+ void setMeatType(String type)


+ String getMeatType()


+ void setCookedStyle(int cookedStyle)
If cookedStyle is invalid, set cookedStyle to MEDIUM

+ String getCookedStyle()
Returns a String representation of the cooked style ('Rare', 'Medium', etc.)

+ String[] getCookedStyles()
Gets an array of cooked styles for meat entrees, in the order listed above.

+ getTax( )
The entree tax amount, plus $1.00

+ String getDesc( )
Returns the values for entrees, plus, meat type and cooked style.



Vegetarian extends Entree
- String servingTemp
e.g. Warm, hot, cold, etc.


+ Vegetarian(String name, String ethnic, String servingTemp, float price, int calories, boolean onPremise )


+ void setServingTemp(String servingTemp)


+ String getServingTemp( )


+ getTax( )
The default tax amount for an entree

+ String getDesc( )
Returns the values for entrees, plus, serving temperature.



Dessert extends Food
- boolean cold
true: Serve cold

- boolean hot
true: Serve hot


Note that a Dessert can be served both hot and cold, such as pie a la mode.


+ Dessert(String name, boolean cold, boolean hot, float price, int calories)


+ void setCold( boolean cold )


+ boolean getCold( )


+ void setHot( boolean hot )


+ boolean getHot( )


+ getTax( )
The default tax amount for food.

+ String getDesc( )
Returns 'Yes' or 'No' for each of hot and cold status (e.g. 'Hot = Yes Cold = No')
Jay is offline  
Sponsored Links
Advertisement
 
post #2 of 7 Old 07-03-2003, 9:44 AM Thread Starter
Jay
 
Join Date: 05-11-2003
Posts: 1,119
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Reputation Power: 0
 
Re: For Those who asked I post New Java Progams

This is the ODCB db that needs to be LOADED into Your ODCB in found in Windows Control Panel.

Opps, I will have to Email it to any interested.



Jay is offline  
post #3 of 7 Old 07-03-2003, 10:05 AM Thread Starter
Jay
 
Join Date: 05-11-2003
Posts: 1,119
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Reputation Power: 0
 
Re: For Those who asked I post New Java Progams

FoodProject, populates Food Objects in Access db.

FOODDBMS.java 2nd 1/2 under this post. Pretty much, if any1 is interested, let me know I can email the stuff to you.
Quote /*
import java.sql.* ;
import java.io.* ;
import sun.jdbc.odbc.* ;

/* FoodDBMS, class used to read Food Access db and populate 5 food groups (Drink, Appetizer, Meat, Vegetarian, and Dessert)
**creates arrays of the various menu items.
** Look at the 5 'populate___( )' methods right after the constructor method for this class to see how each Food instance is created. You must have a method that matches each of these methods.
*/
public class FoodDBMS extends Object {
private String url, user, password, sql ;
private Statement stmt ;
private Connection con ;
private ResultSet rs ;
private Drink drink[];
private Appetizer appetizer[];
private Meat meat[];
private Vegetarian veggy[];
private Dessert dessert[];
private Entree entree[] ;
private Food food[];
private int currentFood, entrees = 0 ;

/* Constructor does it all!
*/
public FoodDBMS(){
try {
new JdbcOdbcDriver();
url = new String('jdbcdbc:Menu');
user = *new String('');
password = *new String('');
con = DriverManager.getConnection(url, user, password);
stmt = con.createStatement();
setArrays();
populateDrink();
populateAppetizer();
populateMeat();
populateVeggy();
populateDessert();
setFood();
}
catch (Exception e){
e.printStackTrace();
} // END:catch
} //END:FoodDBMS Constructor

/**
** populateDrink reads Menu DBMS & populates an array of
*Drink objects calling this Drink constructor:
**Drink(name, temp, container, price, calories, temp, regulated)
**Have a corresponding Drink constructor to handle this
*/
private void populateDrink(){
int drinks ;
String name, container ;
int temp, calories ;
float price ;
boolean regulated ;
try {
sql = new String('SELECT * FROM Drink ORDER BY name');
rs = stmt.executeQuery(sql);
drinks = 0 ;
while (rs.next()) {
name = rs.getString('Name');
container = rs.getString('Container');
regulated = rs.getBoolean('Regulated');
temp = rs.getInt('ServingTemp');
calories = rs.getInt('Calories');
price = rs.getFloat('Price');
/*
*- Here we create instances of drink food items
*/
drink[drinks++] = new Drink(name, temp, container, price,
calories, regulated);
/*
Above we created instances of drink food items
*/
} //END:while
} // END:try
// catch (InvalidFoodprice ifc){
// System.out.println(ifc.getMessage()) ;
// } // END:catch IFC
catch (Exception e){
e.printStackTrace();
} // END:catch
} //END:populateDrink

/**
** populateAppetizer reads Food DBMS & populates an array of
** Appetizer objects calling this Appetizer constructor:
**Appetizer(name, people, price, calories)
**Have a corresponding Appetizer constructor to handle this
*/
private void populateAppetizer(){
int apps ;
String name ;
int people, calories ;
float price ;
try {
sql = new String('SELECT * FROM Appetizer ORDER BY name');
rs = stmt.executeQuery(sql);
apps = 0 ;
while (rs.next()) {
name = rs.getString('Name');
people = rs.getInt('People');
price = rs.getFloat('Price');
calories = rs.getInt('Calories');
/*
*- Here we create instances of our appetizer food items
*/
appetizer[apps++] = new Appetizer(name, people, price, calories);
/*
*-Above we created instances of our appetizer food items
*/
} //END:while
} // END:try
// catch (InvalidFoodprice ifc){
// System.out.println(ifc.getMessage()) ;
// } // END:catch IFC
catch (Exception e){
e.printStackTrace();
} // END:catch
} //END:populateAppetizer

/**
** populateMeat reads Food DBMS & populates an array of
** Meat objects calling this Meat constructor:
** Meat(name, ethnic, meatType, cookedStyle, price, calories,
** onPremise)
**Have a corresponding Meat constructor to handle this
*/
private void populateMeat(){
int meats ;
String name, ethnic, meatType ;
int calories, cookedStyle ;
boolean onPremise ;
float price ;
try {
sql = new String('SELECT * FROM Meat ORDER BY name');
rs = stmt.executeQuery(sql);
meats = 0 ;
while (rs.next()) {
name = rs.getString('Name');
ethnic = rs.getString('EthnicName');
meatType = rs.getString('MeatType');
cookedStyle = rs.getInt('CookedStyle');
price = rs.getFloat('Price');
calories = rs.getInt('Calories');
onPremise = rs.getBoolean('OnPremise');
/*
-Here we create instances of our meat food items
*/
meat[meats] = new Meat(name, ethnic, meatType, cookedStyle,
price, calories, onPremise);
entree[entrees++] = meat[meats++];
/*
-Above we created instances of our meat food items
*/
} //END:while
} // END:try
// catch (InvalidFoodprice ifc){
// System.out.println(ifc.getMessage()) ;
// } // END:catch IFC
catch (Exception e){
e.printStackTrace();
} // END:catch
} //END:populateMeat

/**
** populateVeggy reads Food DBMS & populates an array of
** Vegetarian objects calling this Vegetarian constructor:
** Vegetarian(name, ethnic, cooked, price, calories, temp,
** cookedStyle, minutes, instructions) *
*Have a corresponding Vegetarian constructor to handle this
*/
private void populateVeggy(){
int veggys ;
String name, ethnic, servingTemp ;
int calories ;
float price ;
boolean onPremise ;
try {
sql = new String('SELECT * FROM Vegetarian ORDER BY name');
rs = stmt.executeQuery(sql);
veggys = 0 ;
while (rs.next()) {
name = rs.getString('Name');
ethnic = rs.getString('EthnicName');
servingTemp = rs.getString('ServingTemp');
price = rs.getFloat('Price');
calories = rs.getInt('Calories');
onPremise = rs.getBoolean('OnPremise');
/*
- Here we create instances of our vegetarian food items
*/
veggy[veggys] = new Vegetarian(name, ethnic, servingTemp,
price, calories, onPremise);
entree[entrees++] = veggy[veggys++];
/*
-Above we created instances of our vegetarian food items
*/
} //END:while
} // END:try
// catch (InvalidFoodprice ifc){
// System.out.println(ifc.getMessage()) ;
// } // END:catch IFC
catch (Exception e){
e.printStackTrace();
} // END:catch
} //END:populateVeggy





Jay is offline  
Sponsored Links
Advertisement
 
post #4 of 7 Old 07-03-2003, 10:06 AM Thread Starter
Jay
 
Join Date: 05-11-2003
Posts: 1,119
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Reputation Power: 0
 
Re: For Those who asked I post New Java Progams

2nd 1/2 of above
Quote /**
* populateDessert reads Food DBMS & populates an array of
* Dessert objects calling this Dessert constructor:
* Dessert(name, cold, price, calories, temp, instructions)
* Have a corresponding Dessert constructor to handle this
*/
private void populateDessert(){
int desserts ;
String name ;
boolean cold, hot ;
int calories ;
float price ;
try {
sql = new String('SELECT * FROM Dessert ORDER BY name');
rs = stmt.executeQuery(sql);
desserts = 0 ;
while (rs.next()) {
name = rs.getString('Name');
cold = rs.getBoolean('Cold');
hot = rs.getBoolean('Hot');
calories = rs.getInt('Calories');
price = rs.getFloat('Price');
/*
- Here we create instances of our dessert food items
*/
dessert[desserts++] = new Dessert(name, cold, hot, price,
calories);
/*
- Above we created instances of our dessert food items
*/
} //END:while
} // END:try
// catch (InvalidFoodprice ifc){
// System.out.println(ifc.getMessage()) ;
// } // END:catch IFC
catch (Exception e){
e.printStackTrace();
} // END:catch
} //END:populateDessert

/*
setFood creates an array of Food objects
*/
private void setFood( ) {
int i, menu, count, maxLen ;
count = getNumberOfFoodItems() ;
maxLen = getMaxCount( );

food = new Food[ count ];

for (i = 0, menu = 0; i < maxLen; i++) {
if (i < drink.length)
food[menu++] = drink[i];
if (i < dessert.length)
food[menu++] = dessert[i];
if (i < meat.length)
food[menu++] = meat[i];
if (i < veggy.length)
food[menu++] = veggy[i];
if (i < appetizer.length)
food[menu++] = appetizer[i];
} // END:for

// Set the current Food to the first one
set( 0 );
return ;
} // END:setFood


/*
Set sets the current Food number
*/
public void set( int food ){
currentFood = food ;
} //END:set

/*
Get gets the current Food number
*/
public int get( ){
return (currentFood) ;
} //END:get

/*
getFood returns an array of all Food objects
*/
public Food[] getFood( ){
return food;
} //END:getFood

private void setArrays(){
int foodCount, entreeCount ;
String drinkCount = new String('SELECT COUNT(*) FROM Drink');
String appetizerCount = new String('SELECT COUNT(*) FROM Appetizer');
String meatCount = new String('SELECT COUNT(*) FROM Meat');
String veggyCount = new String('SELECT COUNT(*) FROM Vegetarian');
String dessertCount = new String('SELECT COUNT(*) FROM Dessert');

foodCount = setFood(drinkCount);
if (foodCount>0)
drink = new Drink[foodCount];

foodCount = setFood(appetizerCount);
if (foodCount>0)
appetizer = new Appetizer[foodCount];

foodCount = setFood(meatCount);
if (foodCount>0)
meat = new Meat[foodCount];
entreeCount = foodCount ;

foodCount = setFood(veggyCount);
if (foodCount>0)
veggy = new Vegetarian[foodCount];
entreeCount += foodCount ;

if (entreeCount > 0)
entree = new Entree[ entreeCount ];

foodCount = setFood(dessertCount);
if (foodCount>0)
dessert = new Dessert[foodCount];
} // END:setArrays

private int setFood(String sql){
int foodCount = 0;
try {
rs = stmt.executeQuery(sql);
rs.next() ;
foodCount = rs.getInt(1);
} // END:try
catch (Exception e){
e.printStackTrace();
} //END:catch
finally {
return foodCount ;
} //END:finally
} // END:setFood

/*
getDrinks returns an array of all Drink objects
*/
public Drink[] getDrinks() {
return drink ;
} // END:getDrinks

/*
getAppetizers returns an array of all Appetizer objects
*/
public Appetizer[] getAppetizers() {
return appetizer ;
} // END:getAppetizers

/*
getMeats returns an array of all Meat objects
*/
public Meat[] getMeats() {
return meat ;
} // END:getMeats

/*
getVegetarians returns an array of all Vegetarian objects
*/
public Vegetarian[] getVegetarians() {
return veggy ;
} // END:getVegetarian


/*
getVegetarians returns an array of all Entree objects
*/
public Entree[] getEntrees() {
return entree ;
} // END:getVegetarian

/*
getDesserts returns an array of all Dessert objects
*/
public Dessert[] getDesserts() {
return dessert ;
} // END:getDesserts

// How many total Food do we have in our menu?
private int getNumberOfFoodItems() {
return( drink.length + dessert.length +
meat.length + veggy.length +
appetizer.length) ;
} // END:getNumberOfFoodItems

// What is the most that we have of any one Food 'type'? Return it!
private int getMaxCount( ) {
int maxLen ;

maxLen = (drink.length < dessert.length) ?
dessert.length : drink.length ;
maxLen = (maxLen < meat.length) ? meat.length : maxLen ;
maxLen = (maxLen < veggy.length) ? veggy.length : maxLen ;
maxLen = (maxLen < appetizer.length) ? appetizer.length : maxLen ;
return (maxLen) ;
} // END:getMaxCount


public static void main(String args[]){
FoodDBMS food ;
food = new FoodDBMS();
System.exit(0);
} //END:main
} //END:FoodDBMS
Jay is offline  
post #5 of 7 Old 07-03-2003, 10:09 AM
 
Join Date: 05-01-2001
Posts: 12,126
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 1 Post(s)
Reputation Power: 0
             
Re: For Those who asked I post New Java Progams

You could put it all into one .TXT file and just attach it to the message.
ConqSoft is offline  
post #6 of 7 Old 07-03-2003, 10:38 AM Thread Starter
Jay
 
Join Date: 05-11-2003
Posts: 1,119
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Reputation Power: 0
 
Re: For Those who asked I post New Java Progams

now there is a solution!

I was in a hurry for class when I posted. Than I decided to skip.
Its West.Civ that I am missing, no biggy.
Jay is offline  
post #7 of 7 Old 07-03-2003, 10:50 AM
 
Join Date: 07-26-2001
Location: NorCal
Age: 44
Posts: 190
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Reputation Power: 19
 
Re: For Those who asked I post New Java Progams

Wow,
Can you do my homework for me?

No really..

Not really...

No REALLY....

No, not really..

Really?

That was the best race I have ever seeen....
knip is offline  
Reply

  Lower Navigation
Go Back   Honda Motorcycles - FireBlades.org > Other > Off-Topic

Quick Reply
Message:
Options

Register Now



In order to be able to post messages on the Honda Motorcycles - FireBlades.org forums, you must first register.
Please enter your desired user name, your email address and other required details in the form below.

User Name:
Password
Please enter a password for your user account. Note that passwords are case-sensitive.

Password:


Confirm Password:
Email Address
A valid e-mail address is REQUIRED. You will not have access to any site features until you activate your account using the activation e-mail that is sent to this address.

Email Address:
OR

Log-in










Thread Tools
Show Printable Version Show Printable Version
Email this Page Email this Page



Posting Rules  
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

 
For the best viewing experience please update your browser to Google Chrome