Results 1 to 5 of 5
- 06-05-2011, 05:17 PM #1
Member
- Join Date
- Jun 2011
- Posts
- 2
- Rep Power
- 0
I have troubles with this code ..!
I started to work with eclipse last week.. And i don have any idea what to do with this code,.. In data Structures And Algorithms.. :( Help Me.. !
this is the code
public class MyQueue {
int n = 5;
int[] a = new int[n];
int h = 0;
int t = 0;
public boolean isEmpty()
{
}
public int first()
{
}
public int size()
{
}
public void pushBack(int e)
{
}
public void popFront()
{
}
public void print()
{
System.out.println("------------------------------------------------------------------");
System.out.println("| h \t| t \t| a[0]\t| a[1]\t| a[2]\t| a[3]\t| a[4]\t| size() |");
System.out.println("-------------------------------------------------------------------");
System.out.print("| " + h + "\t| " + t +"\t|");
for(int i=0; i<a.length; i++){
System.out.print(" "+a[i]+ "\t");
}
System.out.println("| "+size()+ "\t|");
System.out.println("-------------------------------------------------------------------\n");
}
public static void main(String[] args)
{
MyQueue q = new MyQueue();
q.pushBack(5);
q.print();
//-----------------
q.pushBack(2);
q.print();
q.pushBack(1);
q.print();
q.pushBack(7);
q.print();
q.pushBack(6);
q.print();
//----------------
q.popFront();
q.print();
q.popFront();
q.print();
q.pushBack(8);
q.print();
q.pushBack(9);
q.print();
}
}
- 06-05-2011, 05:27 PM #2
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
What don't you understand? You have to actually write the methods for the class. The names do a good job describing what the method will do.
Edit: please use code tags, you can edit them in
[code]
YOUR CODE HERE
[/code]
And ask specific questions, if you get errors, post the exact error in code tags, for logic errors, explain them.Last edited by sunde887; 06-05-2011 at 05:31 PM.
- 06-05-2011, 05:39 PM #3
Think about what each method should do, come up with a design to do it, write comments for each method describing what it is supposed to do and how it is going to do it.
Then when the above are done, write the code.
- 06-05-2011, 05:49 PM #4
Member
- Join Date
- Jun 2011
- Posts
- 2
- Rep Power
- 0
This code is written from my teacher.. and i start lessons last week, i dont know what to doo..
can you meet the code plz.. :(
- 06-05-2011, 05:51 PM #5
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
Give what norm said a shot and see what you come up with. Try your best to compute the easiest methods first and work your way up to the challenging ones. If you run into problems, ask specific questions.
Similar Threads
-
Troubles,convert C/C++ Code to Java
By cristianll in forum New To JavaReplies: 1Last Post: 11-15-2009, 02:30 AM -
JOptionPane Troubles
By Tb0h in forum New To JavaReplies: 4Last Post: 08-26-2009, 01:12 PM -
Gif decoding/LZW troubles
By hellochar in forum Advanced JavaReplies: 2Last Post: 07-14-2009, 11:26 PM -
Image troubles
By Theodoreb in forum New To JavaReplies: 24Last Post: 07-14-2009, 12:41 AM -
subclass troubles
By xf021209 in forum New To JavaReplies: 12Last Post: 04-20-2009, 11:46 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks