Help with a simple program.
I need some help writing a simple program. Can anybody help??
thanks to all.
2. HTML Java Source Code Reserved Word Highlighter
Write a program that inputs a Java source code file and outputs a copy of that file with Java keywords surrounded with HTML tags for bold type. For example this input:
public class JavaSource
public static void main ( String[] args )
if ( args.length == 3 )
new BigObject();
else
System.out.println("Too few arguments.");
will be transformed into:
<B>public</B> <B>class</B> JavaSource
<B>public</B> <B>static</B> <B>void</B> main ( String[] args )
<B>if</B> ( args.length == 3 )
<B>new</B> BigObject();
<B>else</B>
System.out.println("Too few arguments.");
In a browser the code will look like this:
public class JavaSource
public static void main ( String[] args )
if ( args.length == 3 )
new BigObject();
else
System.out.println("Too few arguments.");
Here is something that may get you started...
import java.io.*;
import java.util.*;
public class HtmlJava{
public static void main(String arg[]){
if(arg.length!=1){
System.out.println("Usage java HtmlJava sourceFile");
else
new HtmlJava(arg[0]);
HtmlJava(String source){
try{
BufferedReader sourceReader=new BufferedReader(new InputStreamReader(new FileInputStream(source)));
BufferedWriter writer=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(source+"Html.txt")));
Vector keywords=new Vector();
addKeywords(keywords);
String line;
StringTokenizer tokenizer=null;
String word;
while((line=sourceReader.readLine () )!=null){
tokenizer=new StringTokenizer(line);
while(tokenizer.hasMoreTokens()){
word=tokenizer.nextToken();
if(keywords.contains(word)){
writer.write(""+word+" ");
else{
writer.write(word+" ");
writer.write("\r\n");
writer.close();
sourceReader.close();
System.out.println("Output File written to "+source+"Html.txt");
catch(Exception ex){
ex.printStackTrace();
private void addKeywords(Vector keywords){
keywords.addElement ( "abstract");
keywords.addElement( "boolean");
keywords.addElement( "break");
keywords.addElement( "byte");
keywords.addElement( "byvalue");
keywords.addElement( "case");
keywords.addElement( "cast");
keywords.addElement( "catch");
keywords.addElement( "char");
keywords.addElement( "class");
keywords.addElement( "const");
keywords.addElement( "continue");
keywords.addElement( "default");
keywords.addElement( "do");
keywords.addElement( "double");
keywords.addElement( "else");
keywords.addElement( "extends");
keywords.addElement( "false");
keywords.addElement( "final");
keywords.addElement( "finally");
keywords.addElement( "float");
keywords.addElement( "for");
keywords.addElement( "future");
keywords.addElement( "generic");
keywords.addElement( "goto");
keywords.addElement( "if");
keywords.addElement( "implements");
keywords.addElement( "import");
keywords.addElement( "inner");
keywords.addElement( "instanceof");
keywords.addElement( "int");
keywords.addElement( "interface");
keywords.addElement( "long");
keywords.addElement( "native");
keywords.addElement( "new");
keywords.addElement( "null");
keywords.addElement( "operator");
keywords.addElement( "outer");
keywords.addElement( "package");
keywords.addElement( "private");
keywords.addElement( "protected");
keywords.addElement( "public");
keywords.addElement( "rest");
keywords.addElement( "return");
keywords.addElement( "short");
keywords.addElement( "static");
keywords.addElement( "super");
keywords.addElement( "switch");
keywords.addElement( "synchronized");
keywords.addElement( "this");
keywords.addElement( "throw");
keywords.addElement( "throws");
keywords.addElement( "transient");
keywords.addElement( "true");
keywords.addElement( "try");
keywords.addElement( "var");
keywords.addElement( "void");
keywords.addElement( "volatile");
keywords.addElement( "while");
}Hope it helped
Similar Messages
-
Need help with a simple program (should be simple anyway)
I'm (starting to begin) writing a nice simple program that should be easy however I'm stuck on how to make the "New" button in the file menu clear all the fields. Any help? I'll attach the code below.
====================================================
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Message extends JFrame implements ActionListener {
public void actionPerformed(ActionEvent evt) {
text1.setText(" ");
text2.setText("RE: ");
text3.setText(" ");
public Message() {
super("Write a Message - by Kieran Hannigan");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(370,270);
FlowLayout flo = new FlowLayout(FlowLayout.RIGHT);
setLayout(flo);
//Make the bar
JMenuBar bar = new JMenuBar();
//Make "File" on Menu
JMenu File = new JMenu("File");
JMenuItem f1 = new JMenuItem("New");f1.addActionListener(this);
JMenuItem f2 = new JMenuItem("Open");
JMenuItem f3 = new JMenuItem("Save");
JMenuItem f4 = new JMenuItem("Save As");
JMenuItem f5 = new JMenuItem("Exit");
File.add(f1);
File.add(f2);
File.add(f3);
File.add(f4);
File.add(f5);
bar.add(File);
//Make "Edit" on menu
JMenu Edit = new JMenu("Edit");
JMenuItem e1 = new JMenuItem("Cut");
JMenuItem e2 = new JMenuItem("Paste");
JMenuItem e3 = new JMenuItem("Copy");
JMenuItem e4 = new JMenuItem("Repeat");
JMenuItem e5 = new JMenuItem("Undo");
Edit.add(e5);
Edit.add(e4);
Edit.add(e1);
Edit.add(e3);
Edit.add(e2);
bar.add(Edit);
//Make "View" on menu
JMenu View = new JMenu("View");
JMenuItem v1 = new JMenuItem("Bold");
JMenuItem v2 = new JMenuItem("Italic");
JMenuItem v3 = new JMenuItem("Normal");
JMenuItem v4 = new JMenuItem("Bold-Italic");
View.add(v1);
View.add(v2);
View.add(v3);
View.addSeparator();
View.add(v4);
bar.add(View);
//Make "Help" on menu
JMenu Help = new JMenu("Help");
JMenuItem h1 = new JMenuItem("Help Online");
JMenuItem h2 = new JMenuItem("E-mail Programmer");
Help.add(h1);
Help.add(h2);
bar.add(Help);
setJMenuBar(bar);
//Make Contents of window.
//Make "Subject" text field
JPanel row2 = new JPanel();
JLabel sublabel = new JLabel("Subject:");
row2.add(sublabel);
JTextField text2 = new JTextField("RE:",24);
row2.add(text2);
//Make "To" text field
JPanel row1 = new JPanel();
JLabel tolabel = new JLabel("To:");
row1.add(tolabel);
JTextField text1 = new JTextField(24);
row1.add(text1);
//Make "Message" text area
JPanel row3 = new JPanel();
JLabel Meslabel = new JLabel("Message:");
row3.add(Meslabel);
JTextArea text3 = new JTextArea(6,22);
messagearea.setLineWrap(true);
messagearea.setWrapStyleWord(true);
JScrollPane scroll = new JScrollPane(text3,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
//SpaceLine
JPanel spaceline = new JPanel();
JLabel spacer = new JLabel(" ");
spaceline.add(spacer);
row3.add(scroll);
add(row1);
add(row2);
add(spaceline);
add(spaceline);
add(row3);
setVisible(true);
public static void main(String[] arguments) {
Message Message = new Message();
}persiandude wrote:
Topic: Need help with if, else, and which statements and loops.
How would I display 60 < temp. <= 85 in java
System.out.println("60 < temp. <= 85 in java");
another question is how do I ask a question like want to try again (y/n) after a output and asking that everytime I type in yes after a output and terminate when saying No.Sun's [basic Java tutorial|http://java.sun.com/docs/books/tutorial/]
Sun's [New To Java Center|http://java.sun.com/learning/new2java/index.html].Includes an overview of what Java is, instructions for setting up Java, an intro to programming (that includes links to the above tutorial or to parts of it), quizzes, a list of resources, and info on certification and courses.
[http://javaalmanac.com|http://javaalmanac.com]. A couple dozen code examples that supplement [The Java Developers Almanac|http://www.amazon.com/exec/obidos/tg/detail/-/0201752808?v=glance].
jGuru. A general Java resource site. Includes FAQs, forums, courses, more.
JavaRanch. To quote the tagline on their homepage: "a friendly place for Java greenhorns." FAQs, forums (moderated, I believe), sample code, all kinds of goodies for newbies. From what I've heard, they live up to the "friendly" claim.
Bruce Eckel's [Thinking in Java|http://mindview.net/Books/DownloadSites] (Available online.)
Joshua Bloch's [Effective Java|http://www.amazon.com/Effective-Java-2nd-Joshua-Bloch/dp/0321356683/ref=pd_bbs_1?ie=UTF8&s=books&qid=1214349768&sr=8-1]
Bert Bates and Kathy Sierra's [Head First Java|http://www.amazon.com/exec/obidos/tg/detail/-/0596004656?v=glance].
James Gosling's [The Java Programming Language|http://www.bookpool.com/sm/0321349806]. -
Help with a simple program (asap please!)
I'm writing a program that assumes a user will input 4 positive integers, and outputs them in order from smallest to largest. For example... when inputting 3,5,2,6 - the program will output 2,3,5,6. I've gotten the smallest and largest figured out, but I am having trouble getting the middle two. Oh, there's a catch, only if, switch, else. Here is what I've written so far:
package chapter4homework;
import javax.swing.JOptionPane;
public class C4E8 {
public static void main(String[] args) {
String response = null;
int response1 = 0;
int response2 = 0;
int response3 = 0;
int response4 = 0;
int tempdigit1 = 0;
int tempdigit2 = 0;
int digit1 = 0;
int digit2 = 0;
int digit3 = 0;
int digit4 = 0;
response = JOptionPane.showInputDialog("Enter a positive integer:");
response1 = Integer.parseInt(response);
response = JOptionPane.showInputDialog("Enter a second positive integer:");
response2 = Integer.parseInt(response);
response = JOptionPane.showInputDialog("Enter a third positive integer:");
response3 = Integer.parseInt(response);
response = JOptionPane.showInputDialog("Enter a third positive integer:");
response4 = Integer.parseInt(response);
//Beginning of finding the highest positive integer
if (response1>response2 & response1>response3 & response1>response4)
digit4 = response1;
if (response2>response1 & response2>response3 & response2>response4)
digit4 = response2;
if (response3>response1 & response3>response2 & response3>response4)
digit4 = response3;
if (response4>response1 & response4>response2 & response4>response3)
digit4 = response4;
//End of finding the highest positive integer
//Beginning of finding the lowest positive integer
if (response1<response2 & response1<response3 & response1<response4)
digit1 = response1;
if (response2<response1 & response2<response3 & response2<response4)
digit1 = response2;
if (response3<response1 & response3<response2 & response3<response4)
digit1 = response3;
if (response4<response1 & response4<response2 & response4<response3)
digit1 = response4;
//End of finding the lowest positive integer
//Beginning of finding the second highest positive integer (no idea if this is right)
if (response1>digit1 & response1<digit4)
tempdigit1=response1;
if (response2>digit1 & response2<digit4)
tempdigit1=response2;
if (response3>digit1 & response3<digit4)
tempdigit1=response3;
if (response4>digit1 & response4<digit4)
tempdigit1=response4;
if (response1>digit1 & response1<digit4)
tempdigit2=response1;
if (response2>digit1 & response2<digit4)
tempdigit2=response2;
if (response3>digit1 & response3<digit4)
tempdigit2=response3;
if (response4>digit1 & response4<digit4)
tempdigit2=response4;
if (tempdigit1<tempdigit2){
digit2=tempdigit1;
System.out.println(digit1);
System.out.println(digit2);
System.out.println(digit3);
System.out.println(digit4);
}DeLorean wrote:
Thank you for replying, unfortunately, I am in the second week of a basic programming class, and I have no idea what you mean by recursion, or how to apply it using these simple statements.Hmm, then maybe they're trying to get you to do it the simplistic but hard way, in order to show you the advantages of doing it the proper way...
Regarding the bubble sort, think of it this way: You have four numbers, and you can sort them in three "passes"
First pass: Starting from the fourth number, keep comparing to the previous number and swapping if it is smaller. By the end of this pass, the smallest number will have bubbled to the bottom. This will take three comparison/swap operations.
Second pass: Again, starting from the fourth number, keep comparing to the previous number and swapping if it is smaller. You will stop after comparing the second and third number, because the first number will already hold the smallest number. This will take two comparison/swaps.
Third pass: Same as before, just one less comparison/swap.
And you're done. -
Help with a simple program please
Hello, I am trying to create a java program that will request a password from the user (just input no gui fancy stuff) and give the user 5 tries to get it right. After the 4th guess, it needs to go from "You have # trials left." to "You have 1 trial left." It needs to become singular.
I have successfully created a program that does this, but it uses 5 if statements and 1 while. I was curious as to if there was a way to make this more "pretty" to look at. Perhaps eliminate some of the ifs. I'm not sure, but some help would be great. Thanks!Sorry, this is lessakilla. It seems I have two accounts here. I'll look into fixing that. But here is my dilemma still.
Well, I'm looking for a cleaner look. My program works fine and does what I want it to do, but i was wondering if I could somehow eliminate some of the if statements. There is a skeleton of the program below. Thanks in advance!
while count < 3
if guess.equals(password)
print (correct. welcome)
print (incorrect, you have (4 - count) trials left.)
++count;
}Then I have this
if count == 3
if guess.equals(password)
print (correct. welcome)
print (incorrect, you have (4 - count) trial left.)
++count;
}Finally I have this
if count == 4
if guess.equals(password)
print (correct. welcome)
print (incorrect, you lose.)
}Edited by: vegunks on Oct 9, 2007 7:35 PM -
Need help with a simple process with FTP Adapter and File Adapter
I am trying out a simple BPEL process that gets a file in opaque mode from a FTP server using a FTP adapter and writes it to the local file system using a File Adapter. However, the file written is always empty (zero bytes). I then tried out the FTPDebatching sample using the same FTP server JNDI name and this work fine surprisingly. I also verified by looking at the FTP server logs that my process actually does hit the FTP server and seems to list the files based on the filtering condition - but it does not issue any GET or RETR commands to actually get the files. I am suspecting that the problem could be in the Receive, Assign or Invoke activities, but I am not able identify what it is.
I can provide additional info such as the contents of my bpel and wsdl files if needed.
Would appreciate if someone can help me with this at the earliest.
Thanks
Jaypersiandude wrote:
Topic: Need help with if, else, and which statements and loops.
How would I display 60 < temp. <= 85 in java
System.out.println("60 < temp. <= 85 in java");
another question is how do I ask a question like want to try again (y/n) after a output and asking that everytime I type in yes after a output and terminate when saying No.Sun's [basic Java tutorial|http://java.sun.com/docs/books/tutorial/]
Sun's [New To Java Center|http://java.sun.com/learning/new2java/index.html].Includes an overview of what Java is, instructions for setting up Java, an intro to programming (that includes links to the above tutorial or to parts of it), quizzes, a list of resources, and info on certification and courses.
[http://javaalmanac.com|http://javaalmanac.com]. A couple dozen code examples that supplement [The Java Developers Almanac|http://www.amazon.com/exec/obidos/tg/detail/-/0201752808?v=glance].
jGuru. A general Java resource site. Includes FAQs, forums, courses, more.
JavaRanch. To quote the tagline on their homepage: "a friendly place for Java greenhorns." FAQs, forums (moderated, I believe), sample code, all kinds of goodies for newbies. From what I've heard, they live up to the "friendly" claim.
Bruce Eckel's [Thinking in Java|http://mindview.net/Books/DownloadSites] (Available online.)
Joshua Bloch's [Effective Java|http://www.amazon.com/Effective-Java-2nd-Joshua-Bloch/dp/0321356683/ref=pd_bbs_1?ie=UTF8&s=books&qid=1214349768&sr=8-1]
Bert Bates and Kathy Sierra's [Head First Java|http://www.amazon.com/exec/obidos/tg/detail/-/0596004656?v=glance].
James Gosling's [The Java Programming Language|http://www.bookpool.com/sm/0321349806]. -
Hi, I'm not sure if I'm allowed to post questions on this forum but I can't find anywhere to talk to helpful people about programming.
I'm making a dnd interface for JComponents. So far I've made a simple program that has a Component that can be lifted from a container and braught to the glass pane then later moved to anywhere on the screen and dropped into the container below it. Here's where my problems come:
1) Rite now my 'Movable Component' is a JPanel which is just colored in. I want to either take a Graphic2d from a JComponent/Component and draw it on the JPanel or change the JPanel to the component I want to paint and disable the component.
The problem with getting the Graphics2d is that if the component isn't on the screen it doesn't make a graphic object. I tried messing with the ui delicate and overriding parental methods for paintComponent, repaint, and that repaintChildren(forget name) but I haven't had luck getting a good graphics object. I was thinking of, at the beginning of running the program, putting 1 of each component onto the screen for a second then removing it but I'd rather not. I'd also like to change the graphics dynamicly if someone stretches the component there dropping and what not.
The problem with disabling is that it changes some of the visual features of Components. I want to be able to update the Component myself to change how it looks and I don't want disabling to gray out components.
I mainly just dont want the components to do any of there normal fuctions. This is for a page builder, by the way.
Another problem I'm having is that mouseMotionListener is allowing me to select 2 components that are on top of one another when there edges are near each other. I don't know if theres a fix to this other than changing the Java Class.
My next problem is a drop layout manager, but I'm doing pretty good with that rite now. It'll problem just move components out of the way of the falling component.
One last thing I need help with is that I don't want the object that's being carried to go across the menu bar and certain areas. When I'm having the object being carried I have it braught up to the glass pane which allows it to move anywhere. Does anyone have any idea how I could prevent the component from being over the menu bars and other objects? I might have to make 1 panel is the movable area that can then be broken down into the 'component bank', 'building page' and whatever else I'm gonna need.
This is all just test code to get together for when I make the real program but I need to make sure it'll be possible without a lot of hacking of code.
Sorry for the length. Thanks for any help you can give.The trick to making viewable components that have no behaviour, is to render them onto an image of some sort (eg a BufferedImage). You can then display the Image on a JLabel that can be dragged around the desktop.
Here is a piece of code that does the component rendering for you. This particular example uses a fixed component size, but you can modify that as you choose of course...public class JComponentImage
private static GraphicsConfiguration gConfig;
private static Dimension compSize = new Dimension(80, 22);
private static Image image = null;
public static Image getImage(Class objectClass)
if (gConfig == null)
GraphicsEnvironment gEnv = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gDevice = gEnv.getDefaultScreenDevice();
gConfig = gDevice.getDefaultConfiguration();
image = gConfig.createCompatibleImage(compSize.width, compSize.height);
JComponent jc = (JComponent) ObjectFactory.instantiate(objectClass);
jc.setSize(compSize);
Graphics g = image.getGraphics();
g.setColor(Color.LIGHT_GRAY);
g.fillRect(0, 0, compSize.width, compSize.height);
g.setColor(Color.BLACK);
jc.paint(g);
return image;
}And here is the class that makes the dragable JLabel using the class above...public class Dragable extends JLabel
private static DragSource dragSource = DragSource.getDefaultDragSource();
private static DragGestureListener dgl = new DragMoveGestureListener();
private static TransferHandler th = new ObjectTransferHandler();
private Class compClass;
private Image image;
Dragable(Class compClass)
this.compClass = compClass;
image = JComponentImage.getImage(compClass);
setIcon(new ImageIcon(image));
setTransferHandler(th);
dragSource.createDefaultDragGestureRecognizer(this,
DnDConstants.ACTION_COPY,
dgl);
public Class getCompClass()
return compClass;
}Oh and here is ObjectFactory which simply instantiates Objects of a given class and sets their text to their classname (very crudely)...public class ObjectFactory
public static Object instantiate(Class objectClass)
Object o = null;
try
o = objectClass.newInstance();
catch (Exception e)
System.out.println("ObjectFactory#instantiate: " + e);
String name = objectClass.getName();
int lastDot = name.lastIndexOf('.');
name = name.substring(lastDot + 1);
if (o instanceof JLabel)
((JLabel)o).setText(name);
if (o instanceof JButton)
((JButton)o).setText(name);
if (o instanceof JTextComponent)
((JTextComponent)o).setText(name);
return o;
}Two more classes required by this codepublic class ObjectTransferHandler extends TransferHandler {
private static DataFlavor df;
* Constructor for ObjectTransferHandler.
public ObjectTransferHandler() {
super();
try {
df = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType);
} catch (ClassNotFoundException e) {
Debug.trace(e.toString());
public Transferable createTransferable(JComponent jC) {
Transferable t = null;
try {
t = new ObjectTransferable(((Dragable) jC).getCompClass());
} catch (Exception e) {
Debug.trace(e.toString());
return t;
public int getSourceActions(JComponent c) {
return DnDConstants.ACTION_MOVE;
public boolean canImport(JComponent comp, DataFlavor[] flavors) {
if (!(comp instanceof Dragable) && flavors[0].equals(df))
return true;
return false;
public boolean importData(JComponent comp, Transferable t) {
JComponent c = null;
try {
c = (JComponent) t.getTransferData(df);
} catch (Exception e) {
Debug.trace(e.toString());
comp.add(c);
comp.validate();
return true;
public class ObjectTransferable implements Transferable {
private static DataFlavor df = null;
private Class objectClass;
ObjectTransferable(Class objectClass) {
try {
df = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType);
} catch (ClassNotFoundException e) {
System.out.println("ObjectTransferable: " + e);
this.objectClass = objectClass;
* @see java.awt.datatransfer.Transferable#getTransferDataFlavors()
public DataFlavor[] getTransferDataFlavors() {
return new DataFlavor[] { df };
* @see java.awt.datatransfer.Transferable#isDataFlavorSupported(DataFlavor)
public boolean isDataFlavorSupported(DataFlavor testDF) {
return testDF.equals(df);
* @see java.awt.datatransfer.Transferable#getTransferData(DataFlavor)
public Object getTransferData(DataFlavor arg0)
throws UnsupportedFlavorException, IOException {
return ObjectFactory.instantiate(objectClass);
}And of course the test class:public class DragAndDropTest extends JFrame
JPanel leftPanel = new JPanel();
JPanel rightPanel = new JPanel();
Container contentPane = getContentPane();
Dragable dragableJLabel;
Dragable dragableJButton;
Dragable dragableJTextField;
Dragable dragableJTextArea;
* Constructor DragAndDropTest.
* @param title
public DragAndDropTest(String title)
super(title);
dragableJLabel = new Dragable(JLabel.class);
dragableJButton = new Dragable(JButton.class);
dragableJTextField = new Dragable(JTextField.class);
dragableJTextArea = new Dragable(JTextArea.class);
leftPanel.setBorder(new EtchedBorder());
BoxLayout boxLay = new BoxLayout(leftPanel, BoxLayout.Y_AXIS);
leftPanel.setLayout(boxLay);
leftPanel.add(dragableJLabel);
leftPanel.add(dragableJButton);
leftPanel.add(dragableJTextField);
leftPanel.add(dragableJTextArea);
rightPanel.setPreferredSize(new Dimension(500,500));
rightPanel.setBorder(new EtchedBorder());
rightPanel.setTransferHandler(new ObjectTransferHandler());
contentPane.setLayout(new BorderLayout());
contentPane.add(leftPanel, "West");
contentPane.add(rightPanel, "Center");
public static void main(String[] args)
JFrame frame = new DragAndDropTest("Drag and Drop Test");
frame.pack();
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setVisible(true);
}I wrote this code some time ago, so it won't be perfect but hopefully will give you some good ideas.
Regards,
Tim -
Hello
I am very new to Java and am currently studying a course in the language.
I am working through a tutorial at the moment and a question has been asked and I am struggling a bit
I have been given the code to a program that creates a window with a ball bouncing around inside the window.
There are 2 classes (code below) - Call class - this contains all the code need to create the ball and BallWorld Class (the main Class) this create the window and moves the ball, it also detects if the ball hits the edge of the window, whne this happens it redirects the ball. I understand how all this code works
I have been asked the following:-
Rather than testing whether or not the ball has hit the wall in the nmain program, we could use inhertitance to provide a specialized forom of Ball. Create a class BoundedBall that inherits from the class Ball. The constructor for this class should provide the height and width of the window, which should be maintained as data fields in the class, rewrite the move method so that the ball moves outside the bound, it automatically reflects its direction. Finally rewrite the BallWorld class to use an instance of BoundedBall rather than ordianary Ball, and elimiante the bounds test in the main program.
I am having trouble with this and I can not get my code to work, I think I may be going in completly the wrong direction with the code can sombody please provide me with a simple working code for both the BoundedBall and ammended BallWorld class, as this will help me understand whare I am going wrong
Ball class
//a generic round colored object that moves
import java.awt.*;
public class Ball {
public Ball (Point lc, int r) { //constructor for new ball
//ball centre at point loc, radius rad
loc = lc;
rad = r;
protected Point loc; //position in window
protected int rad; //radius of ball
protected double changeInX = 0.0; //horizontal change in ball position in one cycle
protected double changeInY = 0.0; //vertical change in ball position in one cycle
protected Color color = Color.blue; //colour of ball
//methods that set attributes of ball
public void setColor(Color newColor) {color = newColor;}
public void setMotion(double dx,double dy)
{changeInX = dx; changeInY = dy;}
//methods that access attributes of ball
public int radius() {return rad;}
public Point location() {return loc;}
//methods to reverse motion of the ball
public void reflectVert(){ changeInY = -changeInY; }
public void reflectHorz(){ changeInX = -changeInX; }
//methods to move the ball
public void moveTo(int x, int y) {loc.move(x,y);}
public void move(){loc.translate((int)changeInX, (int)changeInY);}
//method to display ball
public void paint (Graphics g) {
g.setColor(color);
g.fillOval(loc.x-rad, loc.y-rad, 2*rad, 2*rad);
BallWorld class
//A bouncing ball animation
import java.awt.*; //import the awt package
import javax.swing.JFrame; //import the JFrame class from the swing package
public class BallWorld extends JFrame{
public static void main (String [] args){
BallWorld world = new BallWorld(Color.red);
world.show();
for(int i = 0; i < 1000; i++) world.run();
System.exit(0);
public static final int FrameWidth = 600;
public static final int FrameHeight = 400;
private Ball aBall = new Ball(new Point (50,50),20);
private BallWorld(Color ballColor) { //constructor for new window
//resize frame, initialize title
setSize(FrameWidth, FrameHeight);
setTitle("Ball World");
//set colour and motion of ball
aBall.setColor(ballColor);
aBall.setMotion(3.0, 6.0);
public void paint (Graphics g) {
//first draw the ball
super.paint(g);
aBall.paint(g);
public void run(){
//move ball slightly
aBall.move();
Point pos =aBall.location();
if ((pos.x < aBall.radius()) ||
(pos.x > FrameWidth - aBall.radius()))
aBall.reflectHorz();
if ((pos.y < aBall.radius()) ||
(pos.y > FrameHeight - aBall.radius()))
aBall.reflectVert();
repaint();
try{
Thread.sleep(50);
} catch(InterruptedException e) {System.exit(0);}Here - you can study this :0))import java.awt.*;
import javax.swing.*;
public class MovingBall extends JFrame {
mapPanel map = new mapPanel();
public MovingBall() {
setBounds(10,10,400,300);
setContentPane(map);
public class mapPanel extends JPanel {
Ball ball = new Ball(this);
public void paintComponent(Graphics g) {
super.paintComponent(g);
ball.paint(g);
public class Ball extends Thread {
mapPanel map;
int x = 200, y = 20, xi = 1, yi = 1;
public Ball(mapPanel m) {
map = m;
start();
public synchronized void run(){
while (true) {
try{
sleep(10);
catch(InterruptedException i){
System.out.print("Interrupted: ");
move();
public void move() {
map.repaint(x-1,y-1,22,22);
if (x > map.getWidth()-20 || x < 0) xi = xi*-1;
if (y > map.getHeight()-20 || y < 0) yi = yi*-1;
x = x + xi;
y = y + yi;
map.repaint(x-1,y-1,22,22);
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D)g;
g2.setColor(Color.red);
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2.fillOval(x,y,20,20);
g2.dispose();
public static void main(String[] args) {
new MovingBall().show();
} -
I'm a beginner to java and i really have no clue..
I have a few programs that need to be done by tonight - been trying to make sense of it, but i dont seem to be getting anywhere.
is there anyone that can help me??
1..)
Write a program which asks the user to enter an integer, a double and a String, then prints out these lines:
The integer plus one using the increment operator.
Cast the double into an integer and print it out.
The remainder of the integer divided by the double. Cast the double into an integer first and use the remainder operator.
The String in quote marks (").
Assume the integer and the double are the dimensions of a rectangle then print the area of the rectangle (as a double).
Each output line must have an explanation. E.g.
Value of integer plus one is:
2)
Write a program which calculates a price (in $�s) then adds tax (at 15%) and P&P (Post and Packing) at $4.50.
Ask the user for a value (double)
Print out nicely the original value
Print out nicely the new value which is the original value plus tax and P&P.
3)
Write a program which asks the user to enter 3 values - a double less than 50.0, an integer greater than 5 but less than 100 and a String. (You need not bother checking these!)
Use the Random class to generate a random number between 0 and one less than the integer entered
Printout the total of multiplying together the random number, the length of the String and the double entered.
Important Information
Any help will be appreciated. ThanksUhh...
You are screwed so I will help you out with one of the first tuts I was able to make sense of.
Here is a anual interest program, it really won't be hard to edit it into Tax and it already has the input box.
public class Interest3 {
This class implements a simple program that
will compute the amount of interest that is
earned on an investment over a period of
5 years. The initial amount of the investment
and the interest rate are input by the user.
The value of the investment at the end of each
year is output. The rate must be input as a
decimal, not a percentage (for example, 0.05,
rather than 5).
public static void main(String[] args) {
double principal; // the value of the investment
double rate; // the annual interest rate
TextIO.put("Enter the initial investment: ");
principal = TextIO.getlnDouble();
TextIO.put("Enter the annual interest rate: ");
rate = TextIO.getlnDouble();
int years = 0; // counts the number of years that have passed
while (years < 5) {
double interest = principal * rate; // compute this year's interest
principal = principal + interest; // add it to principal
years = years + 1; // count the current year.
if (years > 1) {
TextIO.put("The value of the investment after ");
TextIO.put(years);
TextIO.put(" years is $");
else {
TextIO.put("The value of the investment after 1 year is $");
TextIO.putln(principal);
} // end of while loop
} // end of main()
} // end of class Interest3So now save that as Interest3.java in a notepad doc under all files in a directory such as Tax on your desktop.
Now here's the longer one...
(I uploaded it so just click the link)
http://www.megaupload.com/?d=04SJA1J2
^^^^^
Save it as TextIO.java under all files in the "Tax" directory.
Compile it using this: (Notepad, all files, Compile.bat in tax directory)
@echo off
title Compile Tax Program
javac *.java
pauseThen run it using this: (Notepad, all files, Run.bat in tax directory)
@echo off
title Run Tax
java Interest3
pauseNow just edit the system.out.println from "Enter the initial investment" to like "Enter the amount of money"
Then "Enter the anual interest rate" to "Enter the tax amount"
Then remove the calculations for 5 years and rewrite that outprintln. If this is incorrect, as I didn't really read your entire post, I'll quickly slap together a tax program. -
Need help with my addressbook program
hi,
i need help with my program here. this one should works as:
- saves user input into a txt file
- displays name of the saved person on the jlist whenever i run the program
- displays info about the person when clicked via textboxes given by reading the txt file where the user inputs are
- should scroll when the list exceeds the listbox
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.JList;
import java.awt.event.ActionListener;
import java.io.*;
import javax.swing.event.*;
import java.io.FilterInputStream;
public class AddressList extends JPanel implements ActionListener
JTextField txt1 = new JTextField();
JTextField txt2 = new JTextField();
JTextField txt3 = new JTextField();
DefaultListModel mdl = new DefaultListModel();
JList list = new JList();
JScrollPane listScroller = new JScrollPane(list);
ListSelectionModel listSelectionModel;
File fob = new File("Address3.txt");
String name;
char[] chars;
public void ListDisplay()
try
RandomAccessFile rand = new RandomAccessFile(fob,"rw");
BufferedReader br = new BufferedReader(new FileReader("Address3.txt"));
if(fob.exists())
while((name = rand.readLine()) != null)
chars = name.toCharArray();
if(chars[0] == '*')
mdl.addElement(name);
list.setModel(mdl);
if(chars[0] == '#')
continue;
else
System.out.println("No such file..");
catch(IOException a)
System.out.println(a.getMessage());
public AddressList()
this.setLayout(null);
listSelectionModel = list.getSelectionModel();
listSelectionModel.addListSelectionListener(new ListInfo());
list.setBounds(10,40,330,270);
listScroller.setBounds(320,40,20,100);
add(list);
add(listScroller);
JLabel lbl4 = new JLabel("Name: ");
lbl4.setBounds(400,10,80,30);
add(lbl4);
JLabel lbl5 = new JLabel("Cellphone #: ");
lbl5.setBounds(400,50,80,30);
add(lbl5);
JLabel lbl6 = new JLabel("Address: ");
lbl6.setBounds(400,90,80,30);
add(lbl6);
JLabel lbl7 = new JLabel("List ");
lbl7.setBounds(10,10,100,30);
add(lbl7);
txt1.setBounds(480,10,200,30);
add(txt1);
txt2.setBounds(480,50,200,30);
add(txt2);
txt3.setBounds(480,90,200,30);
add(txt3);
JButton btn1 = new JButton("Add");
btn1.setBounds(480,130,100,30);
btn1.addActionListener(this);
btn1.setActionCommand("Add");
add(btn1);
JButton btn2 = new JButton("Save");
btn2.setBounds(480,170,100,30);
btn2.addActionListener(this);
btn2.setActionCommand("Save");
add(btn2);
JButton btn3 = new JButton("Cancel");
btn3.setBounds(480,210,100,30);
btn3.addActionListener(this);
btn3.setActionCommand("Cancel");
add(btn3);
JButton btn4 = new JButton("Close");
btn4.setBounds(480,250,100,30);
btn4.addActionListener(this);
btn4.setActionCommand("Close");
add(btn4);
public static void main(String[]args)
JFrame frm = new JFrame("Address List");
AddressList panel = new AddressList();
frm.getContentPane().add(panel,"Center");
frm.setSize(700,350);
frm.setVisible(true);
panel.ListDisplay();
public void actionPerformed(ActionEvent e)
String cmd;
cmd = e.getActionCommand();
if(cmd.equals("Add"))
txt1.setText("");
txt2.setText("");
txt3.setText("");
else if(cmd.equals("Save"))
mdl.addElement(txt1.getText());
list.setModel(mdl);
try
RandomAccessFile rand = new RandomAccessFile(fob,"rw");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
LineNumberReader line = new LineNumberReader(br);
if(fob.exists())
rand.seek(fob.length());
rand.writeBytes("* " + txt1.getText());
rand.writeBytes("\r\n" + "# " + txt2.getText());
rand.writeBytes("\r\n" + "# " + txt3.getText() + "\r\n");
else
System.out.println("No such file..");
txt1.setText("");
txt2.setText("");
txt3.setText("");
catch(IOException a)
System.out.println(a.getMessage());
else if(cmd.equals("Cancel"))
txt1.setText("");
txt2.setText("");
txt3.setText("");
else if(cmd.equals("Close"))
System.exit(0);
class ListInfo implements ListSelectionListener
public void valueChanged(ListSelectionEvent e)
ListSelectionModel lsm = (ListSelectionModel)e.getSource();
int minIndex = lsm.getMinSelectionIndex();
int maxIndex = lsm.getMaxSelectionIndex();
try //*this one should display the info of the person whenever i click the person's name at the list box via textbox.. but i cant seem to get it right since it always display the info of the first person inputed.. i tried to get the program to display them whenever it reads lines with * on them....
File fob = new File("Address3.txt");
RandomAccessFile rand = new RandomAccessFile(fob,"rw");
BufferedReader br = new BufferedReader(new FileReader("Address3.txt"));
LineNumberReader line = new LineNumberReader(br);
if(fob.exists())
for(int i = minIndex; i<=maxIndex; i++)
if(lsm.isSelectedIndex(i))
while((name = rand.readLine()) != null)
chars = name.toCharArray();
if(chars[0] == '#')
continue;
if(chars[0] == '*')
txt1.setText(rand.readLine());
txt2.setText(rand.readLine());
txt3.setText(rand.readLine());
else
System.out.println("No such file..");
catch(IOException a)
System.out.println(a.getMessage());
}the only problem now is about how it should display the right info about the person whenever i click its name on the list.. something about file reading or something, i just cant figure it out.
and also about how to make it scroll once it exceeds the list.. i cant make it work, maybe something about wrong declaration..
thanks in advance..
Edited by: syder on Mar 14, 2008 2:26 AMLike said before, do one thing at a time. At startup, something like:
//put all the content in a list
ArrayList<String> lines = new ArrayList<String>();
while(String line=rand.readLine()!=null) {
lines.add(line);
}If you follow the good advice to create a class to encapsulate the entries, you could populate a list of such entries like this:
static final int ENTRY_SIZE = 3;//you have 3 fields now, better to have a constant if that changes
ArrayList<Entry> entries = new ArrayList<Entry>();
for(int i=0; i<lines.size(); i+=ENTRY_SIZE) {
Entry entry = new Entry(lines.get(i), lines.get(i+1), lines.get(i+2);
entries.add(newEntry);
}You could also do both of the above in one run, but I think you will understand better what's happening if you do one thing at a time.
If you don't want to put the entries in an encapsulating class, you can still access this without looping:
int listStartIdx = <desired_entry_index>*ENTRY_SIZE;
String att1 = lines.get(listStartIdx).substring(1);
String att2 = lines.get(listStartIdx+1).substring(1);
String att3 = lines.get(listStartIdx+2).substring(1); -
Hello. I'm posting in these forums because I really don't know where else to go. I have been trying for the past several days to figure out how to go about writing my program but to no avail. The project requires reading many lines each containing several different elements from a datafile named "DATA". A few examples of some lines from that file:
Department number/Number of units received/Date on which the shipment arrived/Expiration date/Name of Object
0 78 02/03/2001 02/12/2001 apples
0 26 06/03/2001 06/10/2001 lemons
3 62 03/06/2001 03/14/2001 hamburger
What we have to do with this data is read all of it from the file, separate all the different elements, and based on input from the user, sort everything and print it out to the screen. If the user enters 03, the program will show everything that arrived and expired within the month of March, sorted by date.
It is a pretty basic program, but my problem is that I have no idea how to go about reading in this data, putting it into a vector (probably the easiest method) or separating the different elements. I've gone to websites and looked through my textbooks but they didn't help much. If anyone has any resources that could help for writing such a program, or if anyone could offer help in writing the program, I would really appreciate it. I can also show what I've managed to write so far, or more details on how the program should work. Thanks in advance.
Mattsince im not a pro like some of the guys on here :),
and believe me thiers people here, who could write your whole app in a hour.
anyways my advice , would be to do a search on the forums for useing.bufferReader()
i think you would need to read the file in with bufferreader then split up each line useing the stringTokenizer and then use some algorithm to compare
the values and split them up into your vector arrays as needed.
thier is also fileinputStream i think you can use that too. -
Need help with a simple basketball game.
Hi im new here and I need help with making this simple basketball game.
Im trying to recreate this game from this video. Im not sure if he is using as2 or as3
Or if anyone could help me make a game like this or direct me to a link on how to do it It would be greatly appreciated.If you couldn't tell whether it is AS2 or AS3, it is doubtful you can turn it from AS2 into AS3, at least not until you learn both languages. There is no tool made that does it for you.
-
Need help with a rudimentary program
I'm sort of new at this so i need help with a few things... I'm making a program to compile wages and i need answers with three things: a.) what are the error messages im getting meaning? b.) How can i calculate the state tax as 2% of my gross pay with the first $200 excluded and c.) how can i calculate the local tax as a flat $10 with $2 deducted for each dependant. any help is appreciated
Here is what i have so far:
public class WagesAsign1
public static void main(String[] args)
int depend=4;
double hrsWork=40;
double payRate=15;
double grossPay;
grossPay=payRate*hrsWork;
double statePaid;
double stateTax=2.0;
statePaid=grossPay*(stateTax/100);
double localPaid;
double localTax=10.0;
localPaid=grossPay*(localTax/100);
double fedPaid;
double fedTax=10.0;
double taxIncome;
fedPaid=taxIncome*(fedTax/100);
taxIncome=grossPay-(statePaid+localPaid);
double takeHome;
System.out.println("Assignment 1 Matt Foraker\n");
System.out.println("Hours worked="+hrsWork+" Pay rate $"+payRate+" per/hour dependants: "+depend);
System.out.println("Gross Pay $"+grossPay+"\nState tax paid $"+statePaid+"\nLocal tax paid $"+localPaid+"\nFederal tax paid $"+fedPaid);
System.out.println("You take home a total of $"+takeHome);
and these are the error messages so far:
WagesAsign1.java:23: variable taxIncome might not have been initialized
fedPaid=taxIncome*(fedTax/100);
^
WagesAsign1.java:29: variable takeHome might not have been initialized
System.out.println("You take home a total of $"+takeHome);
^edit: figured it out... please delete post
Message was edited by:
afroryan58 -
Can someone help with this simple application
I am taking my first java class and there are limited resourses for the class as far as getting help with coding.
Any hoo if any one can point me in the correct direction from the following information listed below I would be greatfull. I am trying to use the set and get methods on the instance veriables and then I am goign to post the results once I get them workign to a JOption pane window.
examples are most welcome thanks
// Invoice.java
// Homework assignment 3.13
// Student Arthur Clark
public class Invoice // public class
String partNumber;// instance veriable quantity
String partDescription;// instance verialbe partDescription
//constructors
public void setpartNumber( String number, String description )
partNumber = number; //initalize quantity
partDescription = description; // initalize partDescription
}// end constructors
//method getpartNumber
public String getpartNumber()
return partNumber;
}//end method getpartNumber
public String getpartDescription()
return partDescription;
}// end method getpartDescription
public void displayMessage()
//this is the statement that calls getpartNumber
System.out.printf(" part number # \n%s!\n the description", getpartNumber(), getpartDescription() );
} // method displaMessage
}// end method main
// Fig. 3.14 InvoiceTest.java
// Careate and manipulate an account object
import java.util.Scanner;
import javax.swing.JOptionPane;//import JOptionPane
public class InvoiceTest{
// main method begins the exciution of the program
public static void main ( String args [] )
// create Scanner to obtain input from mommand window
Scanner input = new Scanner ( System.in );
// create a Invoice object and assig it to mymethod
Invoice myMethod = new Invoice();
Invoice myMethod2 = new Invoice();
// display inital value of partName, partDescriptoin
System.out.printf( "inital partname is %s\n\n", myMethod.getpartNumber() );
// prompt for and read part name, partDescription
System.out.println( "please enter the Part Number:" );
String theNumber = input.nextLine(); // read a line of text
myMethod.setpartNumber( theNumber ); // set the part name with in the parens
System.out.println();// outputs blank line
myMethod.displayMessage();
System.out.println( "please enter the Part Description" );
String theDescription = input.nextLine(); // read a line of text
myMethod2.setpartDescription( theDescription );// set the part description
System.out.println();// outputs blank line
myMethod2.displayMessage();
}// end main mehtod
}// end class//constructors
public void setpartNumber( String number, String description )
partNumber = number; //initalize quantity
partDescription = description; // initalize partDescription
}// end constructorsThe above code is not a constructor. You do not include a return type, void or anything else. Also, the constructor should be called the same as your class.
public Invoice( String number, String description )
partNumber = number;
partDescription = description;
} Another thing, comments should only be used when it isn't bleedingly obvious what your code is doing.
P.S. is your middle initial C? -
Need help with spell checker program
Hi
I am writing a spell checker program and need help for a simple logic.I have "List" of correctly spelled words and a String array of wrong spelled words.How can I compare both and tell that for eg xyz word is not spelled correctly.BigDaddyLoveHandles wrote:
To learn more about Map, take the collection tutorial: [http://java.sun.com/docs/books/tutorial/collections/index.html]
(Actually, to me it sounds like you have a Set of correctly spelled words and another Set of words which may or may not be correctly spelled, and you want the difference...)That is what it sounds like to me also, and that is easy.
JSG -
Help with a simple 1811 configuration
I have a very basic level of understanding with Cisco products and I need help with what should be simple and even doable by me.
I have a Cisco 1811 integrated router and am simply trying to use it on my home network. I can configure the router with an enable secret password, password encryption, VTY, aux, and cons logins with no issues. The router has 2 Ethernet interfaces, 0 and 1 and 8 switch ports.
The idea is to bring Comcast ISP service into one of the Ethernet ports and then have three machines on the switch ports able to access the Internet. Also I have an off-the shelf wireless router that I thought I would just plug that into an available switch port and allow a wireless AP as well.
This is so simply, that I can't believe I can't figure it out, but I can't.
I set int F1 to DHCP, performed a 'no shut', and connected the ISP's router and have an up and up indication. I have setup a static network with my three machines on the switch ports and enabled all applicable ports and have up and up indications - however, no traffic flow, even amongst my static Layer 2 switched LAN - not even a 'ping'. By my understanding of Layer 2, this should work right now, whether the ISP service is working or not - WHAT AM I DOING WRONG?
The addressing scheme I have ended up on is 172.16.1.0/28
Obviously without the first hurdle cleared, of why the switched LAN doesn’t work, I haven't got any deeper. Do I need to configure NAT? I don't think I would need to in the scenario right?
All of my experience, and none at the CCNA level, has been with larger Cisco equipment. One thing I noticed on the 1811 was that when trying to create a new VLAN, it appears to work yet does not do anything and the 'sh vlans' output returns nothing, not even the VLAN1 I can see with 'sh ip int brief".
Anyway, if anyone has time to help a newbie out I would appreciate it; I’m lost.
Thanks,
JoshThanks for the help Andrew! You know, I think if this was two separate devices (switch and router) I think I would be up and running, but this integrated stuff is throwing me off, not to mention that the IOS is a much older version (I guess) than what I'm used to.
They were throwing this 1811 in the trash can at work, so I just emptied the trash can. I have no documentation at all but I have since found the 1800 series documentation on Cisco.com and have tried to implement the basic configurations cited; with what seems like success, but still no joy. I did have to recover the password and did so with 0x2142, I bypassed the setup and compared the default configuration with what is listed in the documentation and they DO NOT match; I also tried to go through setup mode with the same indications. Additionally I've also learned that the 1800 series is pre-configured on certain options (DHCP, VLAN), which is new to me - I thought Cisco routers were not configured by default - isn't that kind of the point? (By the way, the below port status may not be correct since I now have all the ports unplugged)
Anyway, here is the 'show run' command, the 'sh ip int brief' command, followed by the 'sh version' command:
Show Run
Casino#sh run
Building configuration...
Current configuration : 2006 bytes
version 12.4
service timestamps debug datetime msec
service timestamps log datetime msec
service password-encryption
hostname Casino
boot-start-marker
boot-end-marker
enable secret 5 $1$meWw$nsMTp6US7axi/uE0MWULK.
enable password 7 06535E741C1B584C55
no aaa new-model
ip cef
no ip dhcp use vrf connected
ip dhcp excluded-address 172.16.1.1
ip dhcp pool Casino
import all
network 172.16.1.0 255.255.255.240
default-router 67.165.208.1
dns-server 68.87.89.150
domain-name hsd1.co.comcast.net
no ip domain lookup
ip domain name GinRummy.localhost
ip name-server 68.87.85.102
ip name-server 68.87.69.150
ip auth-proxy max-nodata-conns 3
ip admission max-nodata-conns 3
multilink bundle-name authenticated
archive
log config
hidekeys
interface Loopback0
ip address 172.16.1.1 255.255.255.240
interface FastEthernet0
no ip address
shutdown
duplex auto
speed auto
interface FastEthernet1
ip address dhcp
ip nat outside
ip virtual-reassembly
duplex auto
speed auto
pppoe enable
pppoe-client dial-pool-number 1
interface BRI0
no ip address
encapsulation hdlc
shutdown
interface FastEthernet2
interface FastEthernet3
interface FastEthernet4
interface FastEthernet5
interface FastEthernet6
interface FastEthernet7
interface FastEthernet8
interface FastEthernet9
interface Vlan1
no ip address
ip nat inside
ip virtual-reassembly
interface Dialer0
ip address negotiated
ip mtu 1492
encapsulation ppp
dialer pool 1
ppp authentication chap
ip forward-protocol nd
no ip http server
no ip http secure-server
ip nat pool Casino 172.16.1.2 172.16.1.14 netmask 255.255.255.240
ip nat inside source list 1 interface Dialer0 overload
access-list 1 permit 172.16.1.0 0.0.0.15
dialer-list 1 protocol ip permit
control-plane
line con 0
password 7 080E5916584B4442435E5C
login
line aux 0
password 7 013C135C0A59475A70191E
login
line vty 0 4
password 7 09635B51485756475A5954
login
end
Show IP Interface Brief
Casino#sh ip int brief
Interface IP-Address OK? Method Status Prl
FastEthernet0 unassigned YES NVRAM administratively down do
FastEthernet1 unassigned YES DHCP up do
BRI0 unassigned YES NVRAM administratively down do
BRI0:1 unassigned YES unset administratively down do
BRI0:2 unassigned YES unset administratively down do
FastEthernet2 unassigned YES unset up do
FastEthernet3 unassigned YES unset up do
FastEthernet4 unassigned YES unset up do
FastEthernet5 unassigned YES unset up do
FastEthernet6 unassigned YES unset up do
FastEthernet7 unassigned YES unset up do
FastEthernet8 unassigned YES unset up do
FastEthernet9 unassigned YES unset up up
Vlan1 unassigned YES NVRAM up up
Loopback0 172.16.1.1 YES manual up up
Dialer0 unassigned YES manual up up
NVI0
'show version'
Casino#sh ver
Cisco IOS Software, C181X Software (C181X-ADVIPSERVICESK9-M), Version 12.4(15))
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2008 by Cisco Systems, Inc.
Compiled Thu 24-Jan-08 13:05 by prod_rel_team
ROM: System Bootstrap, Version 12.3(8r)YH12, RELEASE SOFTWARE (fc1)
Casino uptime is 52 minutes
System returned to ROM by reload at 17:09:25 UTC Fri Jul 1 2011
System image file is "flash:c181x-advipservicesk9-mz.124-15.T3.bin"
This product contains cryptographic features and is subject to United
States and local country laws governing import, export, transfer and
use. Delivery of Cisco cryptographic products does not imply
third-party authority to import, export, distribute or use encryption.
Importers, exporters, distributors and users are responsible for
compliance with U.S. and local country laws. By using this product you
agree to comply with applicable laws and regulations. If you are unable
to comply with U.S. and local laws, return this product immediately.
A summary of U.S. laws governing Cisco cryptographic products may be found at:
http://www.cisco.com/wwl/export/crypto/tool/stqrg.html
If you require further assistance please contact us by sending email to
[email protected].
Cisco 1812 (MPC8500) processor (revision 0x400) with 118784K/12288K bytes of m.
Processor board ID FHK120622J3, with hardware revision 0000
10 FastEthernet interfaces
1 ISDN Basic Rate interface
31488K bytes of ATA CompactFlash (Read/Write)
Configuration register is 0x2102
Thanks again for your help,
Josh
Maybe you are looking for
-
MacBook Pro Cannot Connect to Wireless Router
I have a brand new MBP and it won't connect to any non-apple wireless routers - my computer is 2 days old (it's awesome and I love it accept that I can't get wireless connection at home) - wireless router: westell versalink model 327 W - PROBLEM: my
-
How can I get the chapter numbering in automatic directory
How can I get the new pages to take over the chapter numbering in automatic directory.
-
Clarification of the logical structure of sap system & enterprise structure
Dear Sap Gurus, Kindly help me to clarify the following words.I am grateful for answers.Answers will be rewarded with points.Simple & brief explanatios are highly appreciate.Thank you. 1.FI Enterprise Structure my answers:Collection of organization u
-
No keyboard when trying to leave feedback.
I just tried to leave a review in the App Store but the keyboard would not come up to allow input,
-
Web Dynpro popup & popup with table
Hi forum, need an example of a web dynpro popup & popup with table. Thanks! Edited by: Stanley Marsh on Nov 10, 2008 4:21 PM