bibiki 18 Posting Whiz

on one hand, I suspect he must have coded the Machine class, as well. but, I can't see why wouldn't he have e-mail-ed it, and then Java compiler recognizes Machine as a deprecated class, or maybe I am interpreting mistakenly the compiler's complaint?!?!

bibiki 18 Posting Whiz

Norm,
I was given Bio.class by a friend. I decompiled it, and saw that it contains a Machine object. I am not sure if the friend would want me to share their code in entirety, although the file is not used for financial purposes or anything like that. However, this is the error message:

----jGRASP exec: javac -g Bio.java

Bio.java:162: cannot find symbol
symbol : class Machine
location: class Bio
Machine theMachine;
^
Bio.java:23: cannot find symbol
symbol : class Machine
location: class Bio
theMachine = new Machine();
^
Note: Bio.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors

----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.

and these are some methods the Machine class seems to have:

getPEI()
setString(String s)
formatOK()
//AND FIELD VARIABLES: P, E, I
bibiki 18 Posting Whiz

The file I have is Bio.java, and part of it's code is:

Button submitButton;
    Button resetButton;
    Machine theMachine;
    boolean dateEntered;
    Frame dFrame;
bibiki 18 Posting Whiz

I have this file that contains an instance of some Machine object. When I compile the file I have, it says that the class uses a deprecated API, meaning the Machine object. I tried looking for it in this link, but I find nothing. I was wondering if anyone who used Java for a long time knows whether such a class has actually ever existed or not. I am confused. If you know this class has existed, could you please direct me on where to find it. I can't seem to google for it effectively. any advice is appreciated.

bibiki 18 Posting Whiz

that's correct hfx642, I thought of it too. (one would think) if the author wanted his code known, he'd distribute the code. however, I assure you this is something between friends, no business involved. the file in this case is a one-file applet, from long ago. so I guess you see it is not like I am trying to steal someone's code. I was given the file... the applet won't work though, so I want to open the code and try to fix it.

bibiki 18 Posting Whiz

thanks a lot.

bibiki 18 Posting Whiz

I believe the title of my thread explains what I am trying to do... I have a .class file, I need to look at the code has generated the .class. is this possible, and if yes, can you tell me how?

bibiki 18 Posting Whiz

@Kiparsky,
I haven't considered clojure.

@James,
I'll have to look at your way of doing it.

Thank you all. I'll just mark this thread as solved. I think you helped me enough to get a clear idea on how I'll proceed. thanks again.

bibiki 18 Posting Whiz

I have been thinking of making a graphing calculator for practice. However, I do not know how to assign to a variable an expression. What I exactly mean is:

let's say x is a variable, and y a function of x. I can just define the function inside the code, but then, I'd have to change change the source code every time I want to change the function I want to plot. What I want to do is to be able to define y as a function of x through a GUI... I believe I should use JTextField class, but I was wondering if someone could give more accurate direction.

thanks in advance!

bibiki 18 Posting Whiz

one of our professors has even translated the first six chapters with his permission, so we're good. :)

yeah... I should be studying calculus instead.

bibiki 18 Posting Whiz

alright, I'll add the following book:
this is the book we use at school. it is freely distributed.

sneaker commented: thx for adding a book to the thread +4
bibiki 18 Posting Whiz

alright, I see my assumptions as far as mentioning books on threads were wrong. I thought it is a DaniWeb policy not to reference books because this one time I asked about books recommended, I was not directed to any book, and got the impression that the one I asked was trying to just escape answering (which surprised me, because a forum can benefit from such references in many levels). so, when sneaker asked why his post was moved, I thought I was giving him an answer and not judging his posting.

also, I looked at the book's content as well. I read it's chapter one, and chapter on IDEs. You, peter_budo, are right. I am not a complete beginner, but I am far from a professional. however, I intend to be a professional, so I stick my nose on everything programming/java.

bibiki 18 Posting Whiz

welcome :)

bibiki 18 Posting Whiz

go ahead do the sorting. just google for 'bubble sorting in java' and you will find a solution. however, inside your sorting, you need to do parallel rearrangement of your other arrays. hope this helps.

bibiki 18 Posting Whiz

you are welcome. i'm glad i helped!

bibiki 18 Posting Whiz

switch line 87 with line 88. the if statement should be inside the for loop, that means behind the bracket:

for (x = 1 ; x <= 10 ; x++){
if (age[x] <= 24 && bataverage[x] >= .280) //This is where the problem is
{
c.println ("Name: " + name[x]);
c.println ("Age: " + age[x]); //this prints age=0, even though the value stored in the area doesn't=0
c.println ("Position: " + position[x]);
c.println ("Batting Average " + bataverage[x]);
}
}

besides, in lines 80 through 83, you seem to change the values held by elements on array age. i don't know why would you want to do that. i tried compiling your code, but my compiler can't find Console class.

bibiki 18 Posting Whiz

no, the location of if statement is correct, it should be inside your for loop.

bibiki 18 Posting Whiz

you need an if statement. you need to check if a record held on the array you stored information corresponds to a player that is younger than 25 AND that has a batting average greater or equal to .280. is this of any help?

bibiki 18 Posting Whiz

this is exactly what I thought the first time I posted. however, another way, for less code would be the following:

instead of breaking your qualifications string into tokens, you can just check each token extracted from skills against the entire string that is held by qualifications variable. then, each time you find a match, increase counter. this way, counter will always be less than or equal to the number of tokens in your skills string. divide the counter by the number of tokens in skills, and you get your percentage. I figured this out after I checked your code.

I ran your code and it worked fine for me. I liked it.

bibiki 18 Posting Whiz

I suspect you are trying to measure the relevancy between two strings based on how many common substrings they have. if so, then you should build a method that extracts the unique parts of each string and saves them in arrays (my first thought), and then, check which array is longer. extract each element of the longer array, and check if it is in both arrays. if so, increase some int counter variable somewhere. divide counter with the length of your greater array, and you will find out how much of the longer array is contained in your shorter array, measured as a percentage. hope this helps.

bibiki 18 Posting Whiz

not only is it not a question. it is an advertisement and closer to spam than any question gets.

bibiki 18 Posting Whiz

i assume you need to update somewhere your variable i inside your printedges method

bibiki 18 Posting Whiz

could be the derivative a function named u. depends on context. if it is calculus, it most likely is the derivative of u.

bibiki 18 Posting Whiz

I guess... except that the array's indices would be between 0 and 8, so some arithmetic would be necessary, or am I missing something?

bibiki 18 Posting Whiz

I guess you could have an array that holds 1-9. and, each time a number is typed in your text fields, as long as it is between 1 and 9, inclusive, you set the corresponding value in the initial array I suggested to 0. Every time a user types in a number, you would first have to check if the number is still on the array (indicating it hasn't still been typed), and if it is, receive it as input, otherwise, refuse it. hope this helps.

bibiki 18 Posting Whiz

you could also look on the right to your initial post, and you will see 'similar threads.' I know there have been many posts recently on this subject.

bibiki 18 Posting Whiz

another way I could think of doing this is building a two dimensional array of 6*2 length. on one column, you could save the indexes, and on the other, save the actual numbers you want to sort. then sort the array in the column where you have your actual values saved. hope this helps.

bibiki 18 Posting Whiz

if you wanted to get back to six, you'd need to save somewhere the result of 6/2 first. that way, 6 = (6/2)*2 + 6%2, in general a = (a/b)*b + 1%b. (I'm assuming you work with Java, and declare your variables as int since 7/2 = 3 (not 3.5) for Java ints) otherwise, there is no inverse function of modulo function. and please, quit the slang as it makes it necessary to read your posts at least twice.

bibiki 18 Posting Whiz

I am aware that I might sound like I'm taking it personal, but I really am not, I assure you... however, kiparsky, I would like to know why is it that switches are a no-no. is it just because of the reasons we already mentioned, or is there anything else as well?

bibiki 18 Posting Whiz

James,
I tried the code I just wrote, and realized that one can't use switch with data types other than byte, short, char, and int. although my way of doing this task is possible, seems like it is a little laborious.

another lesson learned, and the same mistake repeated (don't ever second guess experience)

bibiki 18 Posting Whiz

I am a little confused here, James. let me explain what exactly I have been thinking, giving some sample code:

public void pickWhichMethodToRun(String s){

     switch(s){
         case "method1":
               method1();
               break;

         case "method2":
               method2();
               break;
         .
         .
         .
         .

         case "method25":
               method25();
               break;

         default:
             System.out.println("haven't picked an existing method");
     }

}

what do you think James? would this work? or should I just try it in some code?

bibiki 18 Posting Whiz

I would recommend jGRASP. it is very easy to use, and it does not have the auto-complete feature of Eclipse. it does have features that make numbering the lines of code easy, as well as indentation. I have tried Eclipse, but left it for jGRASP. hope this helps.

bibiki 18 Posting Whiz

mKorbel,
I never said that switch-case is going to impact the performance in any way whatsoever. however, I think there is a reason why they built the switch-case construct, and I think the reason is to make code easier to write. and since Dean_Grobler asked if he has to write 25 if-else statements, implying he'd rather not, I thought I'd remind him of the switch-case construct... whatever.

bibiki 18 Posting Whiz

if you just want to avoid using if-else for all 25 cases, you can use switch-case.

bibiki 18 Posting Whiz

butz17, you should write that method yourself. it's really not difficult, you should be able to do it. here, I'll help you. Although, as other posters have suggested, using regular expressions is the best way, but not for a complete beginner, which I assume you are.

lets name the method trimming

public String trimming(String s){
   String rez = "";//to hold the result of the method

   //here, write a loop that checks each character of the string s if it is punctuation or not. if it's not, add it to your variable rez. however, be careful to make an exception for the ' character, since it is not punctuation, and may as well be part of a word

   return rez;
}

I hope this helps.

bibiki 18 Posting Whiz

tracydo,
let's say you have octal number 75, which is 61 decimal. if you want to convert to binary, you break 75 to 7 and 5. you convert 7 to binary, which is 111, and 5 to binary, which is 101. you know put the 111 and 101 together, to get 111101, which is the binary equivalent of decimal 61, or octal 75. is it clear now? I think you have not understood the conversion process in the first place. confirm you understood it, and then we'll move on to helping you with writing the code.

bibiki 18 Posting Whiz

007, I think you're right. I included your suggestion for 'trimming' words, but suggested it should be done as a separate method, as kiparsky mentioned it. and yes, regex is I guess the best way to go, I can't see how I forgot about it. :)

bibiki 18 Posting Whiz

when you take the sentence in, you can then you StringTokenizer class to tokenize your sentence using as a token the empty space ' '. this will break your sentence into words. next, make a method that removes punctuation from each word, in case there is any, and save your words, free of punctuation onto some array.
then, loop on this array to find the number of characters on the longest word.

with another loop, System.out each word that has the length you just found in the previous step. hope this helps.

bibiki 18 Posting Whiz

let's say 24546 is an octal number! what it actually says is that you have:

2*8^4 + 4*8^3 + 5*8^2 + 4*8^1 + 6*8^0, which then equals = 8192 + 2048 + 320 + 32 + 6, which then equals 10598 decimal. notice how the power of eight is being reduced by one, which explains "NormR1 has mentioned that each digit character has a value 10 times the next one (for a decimal number). For an octal number, the value of each digit is 8 times. How do I do that?"

however, converting a decimal number into a binary number is different from converting an octal number into a binary number. which one do you want? do you want to convert an octal number directly to a binary number, or do you want to do it converting it to decimal and then to binary? what do you need to do?

bibiki 18 Posting Whiz

ok, your line 5 on your HandMade class is your constructor method for HandMade objects. however, to effectively do what you want to, you'd need to use the 'super' java keyword. just go to the chapter on your book on polymorphism, find info on using 'super' keyword, and I'm sure you'll figure it out. you might also need to read a little about using constructor methods, but it should not be difficult. It's 2 in the morning where I am so I need to sleep. good night.

bibiki 18 Posting Whiz

you have that. your settors are your set-methods (setPrice) and your gettors are your get-methods (getPrice) for Furniture type, but your HandMade and MachineMade are Furniture types as well, because they extend Furniture type... don't get discouraged, you have the solution above, it's easy. take a look at your code and replies!

so, your Furniture class's settors and gettors also 'belong' to your HandMade and MachineMade classes.

bibiki 18 Posting Whiz

I don't really have a solution, but I am writing because I want to subscribe to the thread and see the solution if someone finds it. however, I do have an idea.

If the length of all orders combined is less than the length of the bar, then the waste is always the same, regardless of the chronological order of responding to the orders.

For waste to vary, we'd have to have the combined length of all orders be longer than the bar. This is when the chronological order in which we respond to orders impacts the waste. So I guess you'd need an algorithm for ordering orders in different ways, and seeing which yields less waste. but in this case, I can't see how recursions helps... just ideas.

bibiki 18 Posting Whiz

alright,
when you declared your array, you said that it will hold Furniture objects. and then, you should assign to each cell on your array an actual object. since your HandMade and MachineMade classes both extend your Furniture class, you are safe in assigning to furniture[3] a HandMade (or MachineMade) object. so you are safe coding as follows:

furniture[3] = new HandMade();

//after you have done the above, you proceed with:

//invoke the method that sets the process for your furniture[3] object
//invoke the method that sets the type for your furniture[3] object
//invoke the method that sets the price for your furniture[3] object
//invoke the method that sets the model for your furniture[3] object
//invoke the method that sets the quantity for your furniture[3] object

//and finally, invoke the toString method for your furniture[3] object
furniture[3].toString();

I hope this helps

bibiki 18 Posting Whiz

say you want to set the price of the Furniture object held on 4th cell of your furniture array.

you invoke the setPrice method of that object, that is:

furniture[3].setPrice(price)//that's it. note, though, that furniture[3] is 4th cell, since first is furniture[0]

is this what you need help with? I can't see a setType method anywhere, so I took an example setting the price.

P.S. you could also do this in your constructor method for Furniture class, but in that case you wouldn't need your set-methods. since you have the methods, I assume you are expected to do this not using your constructor method.

bibiki 18 Posting Whiz

yes there is. you can use StringTokenizer class, tokenize your string using an empty space as a token (' ' - this would be your token), and then in a while/for loop, you'd print out a new line every third iteration or so. perhaps there are other ways, but this would work as well... no arrays used. I assume, under the hood, an array is used, but you wouldn't have to go through it...

n3red commented: Tnx +1
bibiki 18 Posting Whiz

well, I don't know then what the problem could be. one final idea is to escape the underline as well, just in case...

echo exec("d:\\example\\php\_exe\\1436.exe");

bibiki 18 Posting Whiz

I guess what you need is a controller class that has a main method inside it. then, in your main method, you instantiate an instance of your IPTPlogin class, and invoke the two methods just as you wrote above.

I can't give you the code, but here is a guideline.

class name as expected in java
    declaration of main method as expected in java
           instantiation of IPTPlogin object
                invocation of first method
                invocation of second method
    mark the end of main method
mark the end of class
bibiki 18 Posting Whiz

try reading each file's name, and classifying your files according to the extensions of the names. you can use strpos() method to find out if a string is a substring of another string, so use that to know if a file's name contains .jpeg, or anything you want. hope that helps.

bibiki 18 Posting Whiz

could be your escape character... try writing the location of your exec file as follows:

d:\\example\\php_exe\\1436.exe

I hope that works.

bibiki 18 Posting Whiz

pardon me. I solved the thread myself. for anyone wishing to know how, I included an if(!is_dir($filename)) statement after line 6, and it all worked fine.