somjit{} 60 Junior Poster in Training Featured Poster

i started html from the book head first html n css , and just in the second chapter , they're talking about having your own website and that it would help out in learning html. i dont really know anything about this, can anyone suggest if having my own website is required for learning? if so , what are the most affordable options... im a student , and ill just be doing this for the learning.

somjit{} 60 Junior Poster in Training Featured Poster

@sultuske : thanks for pointing that out. missed it.
@toldav : you need to treat the finals just as stultuske mentioned , also , instead of keeping dollars and cents and calculating based on them , you can convert it all into cent value , and do all the math stuff based on that. when u have to print something out , just change the cent value to cents n dollars. this will probably save you a lot of code... the adjustMoney() method for one..

the modified code i posted last night , it had a value variable that stored the money as cent value , and this made the code for the compareTo() method a lot easier than the earlier compareMoney() code. see that part , and check it with your original code , should give you an idea of what i mean.

ps:

Thank you for your time

was real sleepy while making the posts last night , perhaps they needed a bit more explanation, do post if there's something troubling you , but yes , also do check out the links i gave you , and try to come up with a rough cut. dosent have to be perfect . :)

somjit{} 60 Junior Poster in Training Featured Poster

first time i talked about comparators , that was because at first glance , i noticed money being taken in from string. didnt see that the integer.parseInt part , or that it was stored as int. ints make life easy. with int you can simply use a compareTo() method of the comparable interface to sort the moneyObject array out. that is what i incorporated into your money class. then just get the last element , and it will give the one with the biggest money.

this video talks about interfaces , and in particular the comparable one.

a basic example : you have an object array , the compareTo method compares the passed object with the one calling it , if caller is greater the the object passed , returned value is +1 , if the caller is smaller , -1 and 0 if both equal. java's Collections.sort(< your objectList >) will take your list , and sort it by its own using the compareTo method you defined. once that is done, just take the last elements from the list. (you can implement a list using arrayLists. arrayLists are pretty easy , read them here) this element will have the biggest money value you want.

try to write your own code based on what iv said here and the above posts. mistakes makes us learn.

ps : its 2:30 in the morning at my part of the world... time for bed for me. will check this …

somjit{} 60 Junior Poster in Training Featured Poster

i did look at them , i taliked about lines 34,35 of this class itself. see my post above again , perhaps you missed out.

this is a slightly modified version of your money class

class Money implements Comparable<Money> { // comparable is an interface that sorts instances of the class in natural order.

    private int dollars;
    private int cents;
    // new 
    private int value;

    public Money(int dollars, int cents) {

        dollars = dollars;
        cents = cents;
        value = dollars * 100 + cents;
        adjustMoney();
    }

    public Money(String m) {

        if (m.charAt(0) == '$')
            dollars = Integer.parseInt(m.substring(1, m.indexOf('.')));
        else
            dollars = Integer.parseInt(m.substring(0, m.indexOf('.')));

        cents = Integer.parseInt(m.substring(m.indexOf('.') + 1));
        value = dollars * 100 + cents;
    }

    public Money() {

        dollars = 0;
        cents = 0;
        value = dollars * 100 + cents;
    }

    public int value() {
        return value;
    }

    private void adjustMoney() {

        if (cents >= 100) {

            dollars++;
            cents -= 100;
        }

        if (cents < 0) {

            dollars--;
            cents += 100;
        }
    }

    // getter methods.
    public int getDollars() {

        return dollars;
    }

    public int getCents() {

        return cents;
    }

    public Money addMoney(Money otherMoney) {

        int newd = dollars + otherMoney.getDollars();
        int newc = cents + otherMoney.getCents();

        return new Money(newd, newc);

    }

    public Money subtractMoney(Money otherMoney) {

        int newd = dollars - otherMoney.getDollars();
        int newc = cents - otherMoney.getCents();

        return new Money(newd, newc);
    }

    // this is the method that does all the comparing. this one in place of your compare money method.
    public int compareTo(Money otherMoney) …
somjit{} 60 Junior Poster in Training Featured Poster
        this.dollars = dollars;
        this.cents = cents;

the "this" parts above will give you errors. the compiler is asking for a class instance whose dollar and cents variables will be updated , but this is being called from inside a static method. static methods/blocks are compiled first, everything else comes afterwards. trying to get instance variables updated within a static block/method is like trying to get the egg of a particular chicken before the chicken is even born. in a bit more formal lingo , static stuff cant see non static stuff , instance variables/methods , (as the name suggests) are associated with an "instance" of a class , statics cannot see these things. this is why ur getting a static related error.

the "this" part should be here

    public Money( int dollars, int cents ) {

        dollars = dollars; // this.dollars = dollars;
        cents = cents; // this.cents = cents;
        adjustMoney();
    }

I start building my MoneyDriver but need help writing the code for the requirements.

seeing your compareMoney() code, im assuming you know about java comparators. if not , check them out here(java api) here and and here.

basically , here is what you should be doing :
1. create an arraylist of money objects
2. sort the arraylist based on money using the comparator (compareMoney() in your case) with the collections.sort mechanism in java.
3. get the last element of the …

somjit{} 60 Junior Poster in Training Featured Poster

not use language specific contructs

sounds good , but its a bit hard for me to understand exactly what that translates to in code.. if you could give an example of that, would be great :)

regarding learning in a short time , i know if i try to hurry i wont learn anything , i just want to get the simple basics as much as i can , so later on , it will be easier to catch the harder stuff as they keep coming. :)

somjit{} 60 Junior Poster in Training Featured Poster

thanks for all the valuable info! this is why im so much into daniweb.
as im a complete beginer in this feild , it will take a few reads of the replies above, coupled with healthy sessions with buddy google to get it all in properly. i apologize beforehand if i end up asking something silly...

If your goal is improve marketable skills in a few weeks and you already have a C background, it will be much easier for you to pick-up C#. Unfortonately, VB is viewed by many as an inferior language (even though it essentially equal to C#).

that is my goal , as im in my last semester at college. regarding background , im more into java than C , although the later was what i started out with.

I hope the college's software selection is just a recommendation and not a requirement.

i asked our tutor about C# and .NET , and he said that after the vb6 project is done , we will be moving on into asp.net , and C# will be used there , and since we know java and vb6 codes , learning asp "is going to be a breeze!" .
taken, with a pinch of salt.

my question here is :

  1. i know basics of java morderately well. will catching C# be easy given this ?
  2. seeing the code examples above , i guess i can write C# code in place of VB …
somjit{} 60 Junior Poster in Training Featured Poster

thank you for that detailed example ! downloading the attachment.. gonna try this out as i already have vb6 installed.

Since this is your first time to learn visual basic then it's better to learn vb.net.

sems ill be doing that . i checked stuff on the net , and i made another post on the vb.net forums. you have already given me a lot of help , if you find the time to see that post , ill be very thankful if you leave some suggestion based on it.

this is the link.

regards.
:)

somjit{} 60 Junior Poster in Training Featured Poster

hi everyone :) im hoping to learn a healthy amount of vb10/12 by the end of the month. mainly to improve my cv and get a better shot at jobs. originally wanted to learn vb6 for a college project , but after a post in daniweb , my ideas are as such : vb6 obsolete , bad , dont learn! vb10/12 good! go for it !

thats basically all the idea i have about all stuff vb.

however , i did read that c# is used in developing vb ( some ideas regarding this matter would help out too! ) and that it is similar in a lot of ways to java, which being my background (along with some c , n html) makes me think that C# - vb10/12 is the combo for me.

i got a softcopy of head first C# , and i think im gonna learn it from there ( as i love the head first series) , but i dont know any good books for vb10/12. need some help there too!

and lastly , i keep going "vb12/10" every time , what should i start with ? 10 or 12 ?
and consedering that i have never touched anything visual basic , what do you guys think will be the best way for me to start the vb+c# journey?

edit: oracle 9i is obsolete , and that is what we were told to use at college(along with vb6), and im not going to listen …

somjit{} 60 Junior Poster in Training Featured Poster

thank you :) really helped me out :)

somjit{} 60 Junior Poster in Training Featured Poster

had tea , now an apple

somjit{} 60 Junior Poster in Training Featured Poster

That having been said, VB6 and Visual Basic.Net are completely different languages

can the same be said for asp.net vs vb.net ? which one would you say would give better results if i learned it. better results as in how much it would help out in the software development market at present.

somjit{} 60 Junior Poster in Training Featured Poster

@Jx Man

Most important is approching method to access database.

the link you gave there , it has a code there.. is that used in linking the database to the frontend? but in our class , they linked it without any code , an excerpt from my notes says

settings > control panel > admin tools > data source ODBC > system DSN > add > MS ODBC for oracle > name > <project name>

i didnt know what to search for on the web to get a compact idea , whatever i searched , came out too complicated for a novice to understand. i apologise if im dragging the post too long , but this is one of the things about vb i really wanted to understand , if the members here could help me on this , that would be immensely helpful!

@Reverend Jim

how much different is vb.net from vb6? i once installed visual studio 2010 , liked the interface a lot , but i think syntax wise it was a bit different. although it could have been that i messed up somewhere and got a false notion.

the reason were doing it with vb6 is that we were told that a lot of enterprises and offices still use vb6 with oracle 9i... because of a_lot_of_reasons_i_summarised_to_be compatibility issues. if it was some regular teacher , maybe wouldnt have listened :P but the guy is a senior consultant , and its hard for us question him... …

somjit{} 60 Junior Poster in Training Featured Poster

thank you for the links!

in college , the backend sql is being implemented with oracle 9i , how much does it change things if i use mysql? sorry if the questions are vague ... i dont really know much about vb or sql.. lot to learn.

i was doing some searches on the net , a few places mentioned a book called "hardcore visual basic" being very good for those coming from another language. and also that the name hardcore was a misnomer , and its a good book. is that so ? can you suggest a few good books too?

many thanks!

somjit{} 60 Junior Poster in Training Featured Poster

hi everyone :)
i want to learn vb6 , but i dont know where to start. I have a college project related to creating banking software where vb6 is being used as the frontend. i have around 1 month to get my vb6 skills up , as the project has already started and im lagging behind (as i dont know vb). i got very varied opinions from my frnds , and it only added to more confusion..
if the members could guide me to some good books/links that would be great! looking forward to a good time with vb. :)

somjit{} 60 Junior Poster in Training Featured Poster

@spowel4 : i apologise for my 1st post, as i google , i see that i didnt comprehend a lot of stuff , and made the post with simple file parsing ideas running in my mind. this is a problem more advanced members.. sorry.

somjit{} 60 Junior Poster in Training Featured Poster

you can pass the level of the shooter to the enemy class , then do a switch case statement like :

        shooting = true;
        switch(level){ // the shooters level

            case 1:
                counter = 20;// reset
                break;
            case 2:
                counter = 10;
                break;
            case 3:
                counter = 5;
                break;
            default:
                break;

        }
somjit{} 60 Junior Poster in Training Featured Poster

i only looked at it for a moment , but :

            Scanner keyboard = new Scanner(System.in);
            .
            .
            input = keyboard.nextInt();
            Scanner scanner = new Scanner(System.in);            

            if(input == 1){
            System.out.println("Enter a new string: ");            
            item = scanner.nextLine(); 

i quite dont get use of having two different scanners, also having a nextLine() after nextInt() might lead to problems (i can only assume this as i cant run your code ). the problem that comes up with such a nextInt() - nextLine() code is that nextline picks up the stray newline character left by nextInt() . however , it can be that the use of different scanners is to work around this problem.... maybe you could provide a version of your code that can be run and tested , will be easier to spot the errors...

also , you haven't mentioned what you want to do with the code..

I have a binary tree, that user types in a string, if the string does not exist, it adds it to the tree, but if it does, it increases the frequency by 1 instead of adding it to the tree.

sounds like a counter implementation.. in that case, if your allowed to use external java library , take a look at TreeMap . its a red black BST implementation that does its stuff (insert , search , delete ) all in logN time. pretty fast.

somjit{} 60 Junior Poster in Training Featured Poster

what do you want the delimiters to be? how do you want to parse it? these are important factors when u decide to parse something, and im unable to get much information regarding these from your code.
personally, iv always used bufferedReader and string split methods for parsing with good results in good timing too , and the file you provided , shouldnt be too hard to parse either. but , need to know about the above two factors.

somjit{} 60 Junior Poster in Training Featured Poster

C , about 4 years ago. but then i didnt have my own pc , and shared work on our college lab's turbo C running machines never seemed fun , especially as we got only 40 mins per week.
it was in early 2010 after getting my own pc , that programming started : with writing matlab code for control system homeworks , and making avr codes (for a line follower i wanted to build).

somjit{} 60 Junior Poster in Training Featured Poster

Although it has been sometime since i last programmed in matlab , if i recollect properly , matlab code , in essence is a lot like C.. ie , procedural. java is OO . also , functions built into matlab , in many cases can be quite complicated , and implement complex algorithms, which can be difficult to translate effectively to java.

If you have done some programming in java , it would be better if you give it some effort yourself, write some startup code based on the algorithm you have in mind , and then post the code you have come up with. the members here would be happy to help you , but you have to show some effort of doing it yourself as well. thats only fair :)

somjit{} 60 Junior Poster in Training Featured Poster

if your problem's solved , please do mark the thread as solved too :)

somjit{} 60 Junior Poster in Training Featured Poster

i hope you have taken a look at the links i asked you too , however , sometimes an example explains best. i modified your code a lot , and instead of all the classes , you have just one class now , the char_array{} class renamed to hangman ( just felt that to be more in place with things ) and the other classes you used to have , iv converted them into methods under the hangman class.

here is the code: (this is a basic stuff that will get you started with ideas)
i kept the chosen word as "pizza" as u'll see in the code , go ahead run it , put the words of pizza , and see what happens.

import java.util.*;

public class hangman {

    private static String[] words = {"insert","moron","fool","bored","crazy","hello","nice","word","brother","senior","junior",
                "glasses","tiny","floor","code","internet","lake","sport","prince","aunt","seven","cartoon","trump","zebra","chalk",
                "random","person","movie","place","thing","rabbi","chest","hairy","clothes","close","open","closed","filled",
                "waste","find","easy","hard","pitch","base","come","twins","cracka","whatever","keyboard","actually","alabama","sixteen","computer","telephone","habitat","hangman","java" };
    public String chosenWord;
    public String x;
    public int counter = 0;//variable to increase in case of double letter. Added to counter in main function.

    public hangman(){
        double r = 1 + Math.random()*words.length;
//      chosenWord = words[(int)r]; // eventually this should be used
        chosenWord="pizza"; // but its good to use what you know while building n testing your code.
//        x = b;

    }

    public void checkInput(Scanner is){
        boolean[] pos = new boolean[chosenWord.length()];
        int counter = 0;
        while(counter!=chosenWord.length()){
            System.out.println("\n enter letter: ");
            String ip = is.nextLine();
            for(int i = 0 ; i < pos.length ; i++){
                if(ip.charAt(0)==chosenWord.charAt(i)){
                    pos[i] = true;
                    counter++;
                } 
        }
            int i = 0;
            while(i<pos.length){
                if(pos[i]) …
somjit{} 60 Junior Poster in Training Featured Poster

main main = new main();
you dont have a Main() class , and main() , rather

public static void main(String[] args){}

in java serves a different purpose.. its the 1st method looked at by the jvm , without it , you cant compile your code.. so seems like a two - way error...
what did you intend on making this do? im sure we can fix that :)

edit : i just looked again , and you do have a main class! sorry about that... i overlooked the main class in the 1st post , but do you need all the different classes for this? it can be all done with one class. also , the graphics class you posted , just keep it as another method inside the char_array() class , and look up at the switch - case statements and how they work , they can really simplify your existing code.

another improvement , something that can make your code much simpler , is using ArrayLists . using that , you can check if the word contains the user input by simply using the contains() method of an arraylist. check these two out. its gonna be fun :)

somjit{} 60 Junior Poster in Training Featured Poster
        System.out.println("How many positions do you want?");
        int userInput = play.nextInt(); // this will lead to problems
        Clown[] circusClowns = new Clown[userInput];
        for (int i = 0; i < circusClowns.length; i++) {
            System.out.print("Enter the name of the clown: ");
            name = play.nextLine();

this part of the posted code will lead to new errors , as the nextInt() method will leave behind a newline character which will be picked up by the nextLine() method , and the program will crash. put an extra play.nextLine(); right below the for() and before the System.out.print("Enter the name of the clown: "); part to catch the stray newline character left in the stream.

As far as I can see, your driver is asking for doubles and your main class is sending ints. So thats never going to work.

seems to work for me.. promotion into a higher byte variable is done automatically , however , if it was a double to int conversion , that would result in an error.
that said, just because java takes care of int to double conversion , we shouldn't knowingly pass int to somthing that asks for a double either, especially when we can do something about it.

somjit{} 60 Junior Poster in Training Featured Poster

thanks , i didnt know about that part. will check it out. :)

somjit{} 60 Junior Poster in Training Featured Poster

welcome to daniweb :)

maybe you could post for the other classes as well , that way members could run it and check out the nuances themselves.. not only that , but it would be more fun too .. :) good to play hangman :)

however , at a first glance , i dont see the role of the counter variable inside the char_array() class , i dont see it being used for anything...
also ,

    public void init(String a, String b){
        word = a;
        x = b;

    }

this is supposed to (re)initialize it... with a new word. and it would have a cascading effect on some_function() as it works with the word initialized by init.
also , i have a feeling that char what_user_sees[] = new char[word.length()]; has a role to play in the re initialization , as what user sees shouldnt get a new char array everytime , rather it should be appended to what is there already...

somjit{} 60 Junior Poster in Training Featured Poster

facebook doesnt help when im down with a code :P
so i can live without the instant updates thing :)
but if there was something that would tell me about the changes , like if got any votes etc.. that would be good , they dont have to be realtime or anything..

somjit{} 60 Junior Poster in Training Featured Poster

i was wondering if there could be some notification system like facebook which pops up a number as soon as something in your daniweb world has changed.
currently , i have to refresh to get the info if im already watching the opened page , and if im opening daniweb , then i have to check the changed coloured balls to get a idea of what has changed.
but this only gives limited info ... all the detailed stuff like posts voted up/down , comments received etc we only get to see that from our profile page , and that too , unless we remeber what our pervious score was , we wont realise if anything has changed or not.

now , im new here , not many posts either , but still i find myself in daniweb for a substantial amount of time these days , and i quite enjoy being here aswell... would love if i could get some instant updates on the changes occuring around me like one gets in facebook. atleast for me , it would make the whole experience even more engaging :)

regards.

somjit{} 60 Junior Poster in Training Featured Poster

this post , isnt much about about java , but more about the numbers themselves .

i think you misunderstood me there... by this post i tried to mean my post(rather reply) and what i was going to write about! i guess i didnt make much sense there.. and yes of course the replies should be java related as this is the java forum , but since you and IIM had already done the java part.. so thought id just say a bit on the numbers.. coz it is an interesting series :)

sorry for the confusion.
regards.

somjit{} 60 Junior Poster in Training Featured Poster

by "client" what iv come to understand is the main method that runs classes and its methods in a particular fashion , to get a particular job done.

u might hear terms like "test client" as such as well... they are basically a tester class with just the main method , and uses many other classes for doing some work.

somjit{} 60 Junior Poster in Training Featured Poster

first of all , welcome to daniweb :)

all the membesrs would love to help you out , but you should to show that you gave an effort to solving the problem too .. c'mon thats only fair :) if things didnt work out like that .. daniweb , or any forum for that matter , would soon become "solve my homework.com" :D

but anyways , as a 1st post bonus : heres a basic skeleton :

keep age as an "int"
use a "scanner" to read your input. syntax will be something like

import java.util.Scanner;
.
.
// code stuff
.
.
int age; 
.
//code stuff again
.
Scanner is = new Scanner(System.in);// this will get input from console
age = is.nextInt();// take the integer and assign it to age

you should get this up running first , with a few print statements. when all that is good and running.. well solve the exception parts as well :)

have fun coding.:)

somjit{} 60 Junior Poster in Training Featured Poster

Can someone explain what the Fibonacci series is?

IIM n <M/> have already added java related information to fibonacci stuff... this post , isnt much about about java , but more about the numbers themselves .

if you have seen/read the da vinci code , u might have heard about the golden ratio. fibonacci numbers are initimately related to the golden ratio as such that two successive fibonacci numbers follow the golden ratio. instances of this ratio , (and thus fibonacci numbers) are abundant in nature.
the ratio of human body parts , size and shape of flower petals , and even rules of framing of a photograph.... there are countless areas where golden ratios and fibonacci series play a very influential part! so as you see , these are quite a set of numbers... !
cool thing to study if you ask me :)
have fun :)

somjit{} 60 Junior Poster in Training Featured Poster

just woke up half an hour ago.. n here in daniweb again :)

arr[0] = [0,1] -> [0,6] -> null

for this there is another way you can do things:

  1. read all the input co ordinates (the vertices of edges) into one array

  2. sort the array in natural order of x- co ordinate , breaking ties by y co ordinate. for this , your linked list class has to implement the comparable interface , and sort it by help of the compareTo() method of the interface. here is a code example :

    // compare by x-coordinate, breaking ties by y-coordinate
    public int compareTo(Edge that) {
        if (this.x < that.x) return -1; // x == vertex1 , y == vertex2
        if (this.x > that.x) return +1;
        if (this.y < that.y) return -1;
        if (this.y > that.y) return +1;
        return 0; // when both are similar
    }
    
  3. In a for loop , run the lop for each new x co ordinate , such that all points with the same x cordinates end up in the same array list . somewhat like this

    for( each new value of x co ordinate in the array){ // since the array is sorted , this will add points in ascending order
        create a new adjacency list
        while( pairs of co ordinates exist with this x){
             keep adding each pair along with the "weight" value related to that pair
             to the newly created arraylist
        }
    }
    
somjit{} 60 Junior Poster in Training Featured Poster

1st of all , i think your complicating your edge class too much... i havent looked at it in detail ,its a lot easier to just keep it as an innerclass of your linked list , and make a constructor as such

        head = new Node(); // in this case Node() will be replaced by Edge()
        head.next = null;
        head.prev = null;
        head.item = null;
        tail = head;

this makes the code easy to work with, ... with a sentinel head / node / edge whichever you wish to call , and then proceed stepwise... i copied your code into eclipse , lets see what more comes up...

edit : can you explain a bit more about the adjacency list? what is it supposed to do? eclipse shows a lot of errors ... an ecplanation of the adjacency part would be helpful in working around those errors :)

somjit{} 60 Junior Poster in Training Featured Poster

Instance variables can be initialized in constructors, where error handling or other logic can be used. To provide the same capability for class variables, the Java programming language includes static initialization blocks.

umm.. whats the difference between class variables and instance variables? i thought they were the same ? i read that we work with instances of the class , instead of the class itself.. so i suppose then the exceptions to this would mean a static class ? like math?

somjit{} 60 Junior Poster in Training Featured Poster

not sure if "more" or "less" random really make much sense mathematically ...

but maybe you could try a switch - case block , and run different code for different cases for different output of the random method.. that way , you can easily write up an increasing number of cases and well.. make it feel more random...

somjit{} 60 Junior Poster in Training Featured Poster

add() can always work without main method.. this is a simple code showing that happening.

import java.util.ArrayList;


public class tester {

    ArrayList<String> arr = new ArrayList<String>();

    public tester(){
        arr.add("sure ");
        arr.add("it ");
        arr.add("does");
        arr.add("... see :) ");
        for(String s : arr)
            System.out.print(s);
    }

    public static void main(String[] args){
        tester t = new tester();
    }

}
somjit{} 60 Junior Poster in Training Featured Poster

you do not want your enemies to collide , but you havent mentioned what you do want them to do when a collision happens or aboout to happen... maybe if you fix that , its will be easier to comeup with algorithms.

one possible way is the particle collision model .. what it does it that it uses a priority queue using a minimum binary heap as the underlying datastructure, which contains time to hit factors between all possible particle (in this case enemies) pairs , and operates on the pair that is the soonest to occur. it sounds complicated , and it is.. its physics part makes me feel like a fish out of water sometimes(mainly because its been many years since iv touched anything physics) but it gets the job done really well.

if your interested in this , you can read this and this here to get a feel for how they can work.

somjit{} 60 Junior Poster in Training Featured Poster

u had "del" and "delNode" , that was a bit confusing... basically , what you have to do is :

temp = curr.next.next; // stores address of node pointed to by the node you want to delete
curr.next.next = null; // node_to_delete now points to null
curr.next = temp; // node prior to the one to delete now points to the node originally pointed to by the deleted node.
somjit{} 60 Junior Poster in Training Featured Poster

instead of

        while(current_node != null)
        {
            System.out.println(current_node.name+"\t"+current_node.age);
            current_node = current_node.next;

        }

do this :

        while(current_node.next != null) // as the head (which the current node has been assinged ) is a sentinel , and actual data starts from the next node
        {
            System.out.println(current_node.name+"\t"+current_node.age);
            current_node = current_node.next;

        }

also , in your constructor :

    public aaa()
    {
        head_node = new node();
        current_node = new node(); // shouldnt this be current_node = head_node ?
    }

im not sure of the advantage that creating a separate node for the "current_node" gives... especially since your assinging the head to the current node in your display method later on.

somjit{} 60 Junior Poster in Training Featured Poster

thank you :) i get it now.

somjit{} 60 Junior Poster in Training Featured Poster

can anyone help me understand this code part ?
this is about binary minimum heap , ie root has the lowest key..
the part of the code im trying to understand checks whether the subtree ( of a certain minHeap pq[1..N] ), rooted at k is also a min heap or not

    private boolean isMinHeap(int k) {
        if (k > N)
            return true;
        int left = 2 * k, right = 2 * k + 1;
        if (left <= N && greater(k, left))
            return false;
        if (right <= N && greater(k, right))
            return false;
        return isMinHeap(left) && isMinHeap(right);
    }

in the 2nd line , i dont understand the if statement... as the array which is used to implement the minheap is [1..N] , shouldnt k>N return false? as a value > N means its out of the array?

this is the full version from where i got the above part.

somjit{} 60 Junior Poster in Training Featured Poster

i guess its something like that... sometimes slows down , sometimes doesnt. its working fine since. just that one morning got haywire.

thanks everyone for helping :)

somjit{} 60 Junior Poster in Training Featured Poster

can you give the customer code?

at first glance , bits of your code seems redundant... like

    public void addCustomer(Customer c) {
        database.add(c);
    }

your already doing this inside the try catch block.. so why keep this?

    public void readCustomerData(String CustomerNames) {
    try {

        File f = new File("CustomerNames.txt");

are you trying to append the .txt to the string to make it a filename? i dont know if that can be done... probably this is the reason why it isnt working...

somjit{} 60 Junior Poster in Training Featured Poster

sure you know how to tell java where to look for what , you did it in your previous code as well :) whenever you write <something>.<another thing> in your code , your telling java to look for that "another thing" thing inside of that "something" thing.

in other words , if you write like isPerfect p = new isPerfect(); in your allPerfect method , your creating a reference, a remote control that the compiler can use from within your allPerfect method to have access to your isPerfect method of your isPerfect class. if both the methods were inside the same class , you wouldnt need the reference.

but now that you hve your reference , you can now access the isPerfect method like so :

instead of if(isPerfect(i)) , you now write if(p.isPerfect(i))
p is your remote , the reference to the isPerfect method , and using that , you can now use whatever methods you have inside of that class. in this case , the isPerfect() method.
(just one thing to remember , that you can call only those that are public, your remote wont give you access to the private stuff.)

edit: i noticed that the main method in the isPerfect method you have posted earlier, one that you said is the same as before , it is designed to check whether or not a single user input is perfect or not. but you want your code to check untill a specified range , and …

somjit{} 60 Junior Poster in Training Featured Poster

it is an usb keyboard... i have one sensor for the mouse from a previous combo pack , and another is this one's as this is new. but till yesterday nothing was the problem.
@reverend Jim : i did check that , but no.. nothing . generally i end most of the unimportant tasks from task manager as chrome and eclipse each take a lot of memory to run.

basically i was doing what i usually do. only this morning.. the keyboard became more like a turtle. however , seems to be fine now... any guesses?

somjit{} 60 Junior Poster in Training Featured Poster

both are good , and usually it depends on the particular code your working in. but if the 1st method can be done , ie if the values to set are known at the time the new instance is created , i cant see why not to use it... makes the code shorter and more compact.
However , when the values to set are not known atthe time you call the new on any object , then you have your default no arg constructor , and set the values at a later time using the setter methods.

somjit{} 60 Junior Poster in Training Featured Poster

from today morning , my keyboard just cant keep up. i type a few words , and then it starts displaying the first letters! quite a trouble this !
i tried google-ing about keyboard becoming slow , but the few forum threads i found suggested a format, but thats not an option for me. is there some way i can turn the keyboard back to normal without drastic steps like a format etc?

somjit{} 60 Junior Poster in Training Featured Poster

i wrote a code to implement some basics of priority queue , but apparantly its not giving desired output. the code is implemented using binary heap as its data structure. i tried tinkering here and there , nut no luck... i want to display a given number of max or min items, but im just getting a random selection of words from the file as output. any help with the code will be great. :)

this is my priority queue code:

public class MaxPQ<Key extends Comparable<Key>> {

    private Key[] pq;
    private int N;

    // create an empty priroty queue
    @SuppressWarnings("unchecked")
    public MaxPQ(int capacity){

        pq = (Key[])new Comparable[capacity+1];
    }

    //insert a key into a priority queue
    public void insert(Key v){
        pq[++N] = v;
        swim(N);
    }

    public int size(){
        return N;
    }

    // delete the max key   
    public Key delMax(){
        Key max = pq[1];
        exch(1,N--);
        sink(1);
        pq[N+1] = null;
        return max;
    }
    public Key delMin(){
        Key min = pq[N--];
        pq[N+1] = null;
        return min;
    }

    // is the priority queue empty  
    public boolean isEmpty(){
        return N == 0;
    }
    private void swim(int k){
        while(k>1 && less(k/2,k)){
            exch(k,k/2);
            k = k/2;
        }
    }
    private void sink(int k){
        while(2*k <= N){
            int j = 2*k;
            if( j < N && less(j,j+1)) j++;
            if(!less(k,j)) break;
            exch(k,j);
            k=j;
        }
    }
    private boolean less(int i,int j){
        return pq[i].compareTo(pq[j]) < 0;
    }
    private void exch(int i , int j){
        Key temp = pq[i];
        pq[i] = pq[j];
        pq[j] = temp;
    }
    public void displayItems(){
        for(Key i : pq) …