Art
Birds
Books
Cats
China
Countries
Cosmetology
Education
English
Studies
Flight
& Space
France
Gifts
Health
Holocaust
Hebrew
Historical
Events
Iraq
Ireland
Israel
Italy
Japan
Japanese
Jewish,
Judaism
Law
Love
Lyrics
Love
Poems
Musicology
Nature
New
York
People
Photography
>>>Professions
Spain
Weather
(1)
The Valentine Shop:
(2) The
Rainbow Valentine Shop:
|
(ExY1)
//import java.io.*;
//import java.util.*; no imports required for this program
class CalorieCounter
{
public static void main(String[] args)
{
//define 3 objects of class CalorieCounter
CalorieCounter t= new CalorieCounter()
;
CalorieCounter y= new CalorieCounter();
CalorieCounter d= new CalorieCounter();
//For each object CalorieCounter (tomato cc, yogurt
cc and diet yogurt cc)
// perform the method total_calories
int tt = t.total_calories("Tomatos",100,20);
System.out.println("100 grams of tomatoes is "+tt);
tt = d.total_calories("Diet-Yogurt",100,40);
System.out.println("100 grams of diet yogurt is "+tt);
tt =y.total_calories("Yogurt", 100,100);
System.out.println("100 grams of yogurt is "+tt);
}
int total_calories(String name, int grams, int cals_per_gram)
{
return grams * cals_per_gram;
}
}
/////================================
|
(ExY2)
class WarningWindow extends
java.awt.Window
{
/* public static void main(String[] args)
{
System.out.println("Hello World!");
}*/
WarningWindow(java.awt.Frame anyFrame) {//a constructor
super(anyFrame);
setBackground(java.awt.Color.red);
}
}
|
(ExY3)
import java.awt.*;
public class WindowExample // example of use of two c\kinds of windows
{
public static void main(String[] args)
{
Frame f = new Frame();
Window w = new Window(f); // standard
Window
w.setSize(200,100);
w.setVisible(true);
w.setLocation(300,300);
// the new red-hued WarningWindow we created
WarningWindow
ww = new WarningWindow(f);
ww.setSize(200,100);
// setSize is in a superclass
ww.setVisible(true);
ww.setLocation(370,370);
}
}
|
Warning and
Disclaimer
We try here to provide simple,
non-professional advice and links to sites that seem
to be trustworthy for more details.
This is no substitute for qualified
medical advice.
Always consult a qualified medical
practioner to confirm any self diagnosis and rule out
other causes. Always consult a qualified medical practioner
regarding medical problems or questions.
This site takes no responsibility
for any loss or claim arising from the use or misuse of
information/"advice" on the site or information or
advice on linked sites, nor from the failure of any reader to
seek or take medical, psychological, legal or any other professionally
qualified advice. This warning/disclaimer applies to every
page of this website, whether it appears there or not.
|
|
|