BestJewSinceJC 700 Posting Maven

Many teachers consider it a violation of academic integrity to post your code online, so you should be careful about putting your name on things and about posting exact code if that is the case with your teacher.

/*
*@author Brock Shelton
*Date: April 12,2010
*Purpose: Write a lotter class that stimulates a lottery
*/

import java.util.Scanner; //imports Scanner class
import java.util.Random; //import Random class


public class Lottery
 {

        private int[] lucky = new int[5];
        private int win;
        private Random r1; 
        private Random r2 = new Random();
        private Random r3 = new Random();
		  private Random r4 = new Random();
		  private Random r5 = new Random();

        private int num1 = r1.nextInt(10);
        private int num2 = r2.nextInt(10);
        private int num3 = r3.nextInt(10);
		  private int num4 = r4.nextInt(10);
		  private int num5 = r5.nextInt(10);

        

        public Lottery()
		  {
            r1 = new Random();

	win = 0;
            getNumbers();
            pick(lucky);
			   output();                      
        }
		  
}

Notice how I changed your 'int win' declaration; you made a common beginner mistake. If you declare a variable inside of a method, the variable no longer exists outside of that method (and cannot be referred to outside of that method). So if you wanted to refer to your 'win' variable that you declared as "private int win" you'd just say "win = ..." or "this.win = ..." inside of a method. If you declare a variable as a class variable (for example, your r1-r5 and num1-num5 variable are all class variables) it can be used inside of any method in the class, and …

BestJewSinceJC 700 Posting Maven

How do you forget your own name?

BestJewSinceJC 700 Posting Maven

http://www.willamette.edu/~gorr/classes/cs231/lectures/chapter9/arrays2d.htm

Read ^. Why do you want to know if the entire array is empty? If you're playing tic tac toe, in order to put a piece somewhere, all that needs to be true is that the spot is empty. Not that the whole board is empty.

BestJewSinceJC 700 Posting Maven

Yeah but I have it written down on paper. Let me type it up for you - just give me a few months. Come back in August.

BestJewSinceJC 700 Posting Maven

I was just replying to comments posted. No need to be a d*ck. But in reply to the link (thanks for that), if employers have to make up the difference anyway, why can't everybody stop tipping and make sure that they pay their staff properly? Like I said, ridiculous system.

I think he was only responding to jwenting, he just has impeccably horrible timing.

BestJewSinceJC 700 Posting Maven

No. Re-read, then run, my previous example. If you try to check theBoard it is going to convert X and O to their integer representations, then it is going to look at the board slot at those integer indexes. I think you have a fundamental misunderstanding of how arrays work.

theBoard[index][otherIndex] holds one character, not two. Therefore, in order to check if the board at indexes 1,2 is empty, and taking jwenting's advice, you would put "if theBoard[1][2] == 0". If you want to check multiple slots on the board, you need to use a for loop.

BestJewSinceJC 700 Posting Maven

Where do you consider one String to end and the next to begin? At a newline character? At a comma? For some other delimiting character or regular expression?

For newlines (\n) you can use Scanner and use the nextLine() method, along with a while loop and the hasNextLine() method to read in each line of your input. A simple counter would allow you to add the Strings you read in into the correct part of your String array.

For commas, other characters, or regular expressions, there are a variety of different ways you can do the same thing (some using Scanner, some not) but I'll refrain from mentioning any of them yet because I assume you mean to break at newlines.

As for sorting, you have the right idea by using the Arrays.sort method, but you can't pass in something like that. An example usage of Arrays.sort would be this:

String[] arr = new String[3];
arr[0] = "blah!";
arr[1] = "haha";
arr[2] = "aaa";
Arrays.sort(arr);
for (String s: arr) System.out.println(s);
BestJewSinceJC 700 Posting Maven

Sorry man, I knew that, but I was thinking about Objects, not about primitive types. Anyway, what I said about only using integers isn't entirely true. You can index the array based on a char but really it is going to convert it into an int first. For example:

char[] chars = new char[1000];
		int theAchar = 'a';
		chars[theAchar] = 'b';
		System.out.println(chars['a']);

Of course, this isn't really helpful for your application whatsoever, especially what you mentioned about checking to see if the board was blank. Again, sorry about the prior misinformation.

BestJewSinceJC 700 Posting Maven
char ch = ''; //Not a valid char
char ch = ' '; //A valid char
System.out.println("blah" + ch + "blah");
BestJewSinceJC 700 Posting Maven

You can only refer to array indexes with integers, not ' ' as you have done. To see if an array is completely empty, you need to use a for loop. I believe array elements are automatically initialized to null, so if you want to check if some element of a 2d array is null try something like this. Oh, and information on arrays is pretty easily found on google. Try it.

if (array[0][0] == null) // put your piece in the array!
BestJewSinceJC 700 Posting Maven

http://www.rollingstone.com/politics/story/29127316/the_great_american_bubble_machine/

An interesting article, no matter what you make of it. I would have comments but I'm not in the know about many of the issues that were described in the article, so I'll refrain for now. It is a long article though, so if you want to read it, be ready to spend at least 30 minutes on it.

BestJewSinceJC 700 Posting Maven

Can you paste us the error messages you get?

BestJewSinceJC 700 Posting Maven

It doesn't really matter if the school is world recognized. Get that out of your head. What you should be concerned with is whether or not your education will be "world recognized".

BestJewSinceJC 700 Posting Maven

Floor mats? Those are for walking on, not for windows...

BestJewSinceJC 700 Posting Maven

I enjoy teaching lower ability students as much as (or even more than) the high flyers. I don't think I'd be as happy "doing my bit" if I was getting penalised for it...

A good bonus system wouldn't penalize you for teaching lower ability kids. Actually, it would encourage it. You might be a great teacher as are many others, but there are also plenty of teachers out there who waste class time etc and they are difficult to discipline. How can you discipline a teacher who is technically doing his/her job, but all he/she is doing is reading out of the textbook, etc, and not being engaging? I've had plenty of teachers like that.

BestJewSinceJC 700 Posting Maven
BestJewSinceJC 700 Posting Maven

You forget #4: an "standard" rate of tipping that's to be a minimum is going to reward poor service, and customers should not reward poor service as that means there's no incentive any longer to give good service (and we see the result all the time with waiters and other staff in the services industry).
And #5: how the heck has a tip, always having been meant as a means of rewarding exceptional service, devolved into being the actual salary of the person it's being handed to, and thus not a reward for exceptional service at all?

Self respect and work ethic: two completely reasonable incentives for good service regardless of where you work and what you do. You do make a good point, which applies to extremely high or low tips, but I disagree that a 15% tip is going to discourage anyone from their usual behavior at work. It also raises the same question that I've asked all along about limits, (if you can afford it, why not tip 30% - it comes down to either conforming to society or what you think the service is worth, both of which I've attempted explaining and debating but the other side is all like "you're a cheapskate"!).

And a tip devolved into being the actual salary when restaurants decided to pay their waiters wages which do not constitute the majority of their waiters' income. If you truly think that a tip is "a reward for exceptional service", then …

BestJewSinceJC 700 Posting Maven

Vernon, you made some good points. A bonus system is feasible, and as long as there is some minimum salary in place, (which obviously for bonuses, there is) I don't have too many objections.

Great point. In a functioning capitalistic society, when the recruitment goes down, the incentives must go up in order to get more recruits. Since teaching in the poor areas is way harder than teaching in the good areas, assuming that teachers are like most other employees, unless they are offered MORE pay to teach in the poor areas, all the good teachers will go to the good areas and teach there, get their bonus more easily, and have a much less stressful job. Seems to me that if we need to offer big bonuses anywhere, it's those poor areas where no one wants to teach in the first place.

That point ignores the actual problem - the school environment caused by unruly behavior, a lack of respect for authority, and a lack of funds - and addresses the teacher's salary levels instead. Improving a teacher's salary will not improve the classroom environment, and will therefore not have the desired effect on a child's education. So all you'd be accomplishing is having better teachers in an environment where they are not capable of changing much. And that is only if the teachers are willing to move to a worse school system based on a better salary. What really needs to be done first is shift the …

BestJewSinceJC 700 Posting Maven

edit, was testing something, sorry.

BestJewSinceJC 700 Posting Maven

Becoming a good programmer isn't about being a genius. Hard work and perseverance are more important than intelligence. A high level of intelligence makes learning easier, but a lower level usually does not make learning impossible. I find it likely that you're being too rough on yourself and your confidence, not your potential, is really to blame. Stop crying and get to work.

BestJewSinceJC 700 Posting Maven

Correct if I'm wrong, but every disagreement that I've read so far in this thread has followed this line of thinking:

1. Some customers tip badly
2. Waiters make lower salaries than they should as a result
3. You should tip 20% to avoid being a bad customer

Can you not see the obvious contradictions and lack of logic in that thought process? The fact that some customers tip badly causes waiters to come home with less money than they deserve. Therefore, any reasonable line of thinking would conclude that these customers are to blame, and that these customers should correct their behavior. Yet the conclusion that some of you in this thread have come to is #3 - that I should "tip 20% to avoid being a bad customer". I'm expected to make up for someone else's bad tip???? Hmmmm

BestJewSinceJC 700 Posting Maven

It doesn't matter if you are the only person in the joint or if there are 1,000 people waiting for food.

That's... exactly what I already said.

... you're implying that I should tip more because during non-busy times waiters have fewer tables. By the same faulty logic, during busier times I should then tip less ...

Like I said, the logic was flawed. So we're agreed on that point.

Again, if you can't afford to tip, you really can't afford to eat out.

Nobody in here claimed or otherwise indicated that ability to tip is the issue here. Rather, what was being debated was the preferred amount of tipping and the social issues behind tipping in general. I'm sure there are people who can't afford to tip. Why do you assume that anyone in here is one of them?

Believe me, there is nothing more frustrating than having a 10-top (10 people at a table, which usually takes up 3 tables) which may or may not be your entire section. Spending a large amount of time on that table at the deficit of your other remaining tables. Then have the 10 people run up a $1,000 dollar bill (it's not that far-fetched) and then leave you a $50 tip.

That is a 5% tip. In a nutshell, what was being debated here was why a 20% tip is suddenly seen as socially acceptable whereas a 15% tip, which used to be seen as socially acceptable, is …

BestJewSinceJC 700 Posting Maven

Nobody is going to do your hw, go away

BestJewSinceJC 700 Posting Maven

Because the default constructor for Date implicitly gets you a Date object reference referring to the system date/time at moment of creation.

Doing it like you do here is therefore redundant.

http://java.sun.com/j2se/1.5.0/docs/api/java/sql/Date.html

So that is no longer correct? Or why else isn't it listed there.

BestJewSinceJC 700 Posting Maven

Remote Desktop is disabled by default in Windows 7 or Vista, but it’s easy enough to turn it back on. If you need to access your Vista PC from another box, it’s an essential thing to turn on.
To get to the configuration page, you can either right-click the Computer icon and choose properties, or you can type in system into the start menu search box, and then find the entry for System.
Now you’ll want to click the Remote Settings link on the left hand side:
Now you can finally turn it on:
To connect from another Vista / Win7 PC on the same network, click the bottom radio button. If you need to connect from an XP/2k machine, click the “Allow connections from computers running any version of Remote Desktop” radio button.
Don’t worry about setting up firewall rules, Vista or Windows 7 does that for you

I already did all that, but I was wondering how I'm actually supposed to connect to my sister's machine. When I entered her IP address it just didn't do anything. I guess I'll use better software or software that I understand instead. Btw, if anyone needs this in the future, the steps I took to get rid of the virus were as follows:

http://www.malwarehelp.org/ave-exe-a-multiple-rogues-in-one-trojan-fakerean-2010.html

Except in step 1 that is listed there, before you run the registry file that he suggests, you should make a backup of your registry by opening regedit …

BestJewSinceJC 700 Posting Maven

Post code that small in the thread, in code tags. And your code contains no while loops.

BestJewSinceJC 700 Posting Maven
BestJewSinceJC 700 Posting Maven

Use code tags. And you should be able to identify the problem area by debugging. Use print statements to determine the state of your variables at important points in your code.

BestJewSinceJC 700 Posting Maven

Use System.out.print, '*'s and '\n'

BestJewSinceJC 700 Posting Maven

You called "this".repaint(). Try doing

if (event.getSource() == menuItem) menuItem.repaint();
BestJewSinceJC 700 Posting Maven

I already gave you step by step directions. What didn't you understand?

BestJewSinceJC 700 Posting Maven

Seems ok to me. Who said it was overkill?

(Although I think you should be using the Calendar class instead of Date..)

BestJewSinceJC 700 Posting Maven

You're attempting to use the variable 'i' but you never declared that variable. And you also didn't follow any of this site's rules.

BestJewSinceJC 700 Posting Maven

If you never set 'back' to anything, then it will always be null. I'm saying you must have forgotten to set it.

BestJewSinceJC 700 Posting Maven

Thanks your previous post helped me get to the last node. However, now I can't get it to go back through the list. I can print the first entry and then, shouldn't

temp=temp.back;

bring me to the second one? I get NullPointerException.

Then you probably never initialized temp.back. Whenever you create a new Node (except for the first Node) you should set its node.back to the previous one.

BestJewSinceJC 700 Posting Maven

No, teachers should not be paid based on their students' performance. Any accurate measure of performance is impossible to achieve, and teachers cannot force students to learn material, they only present the material. Teachers also cannot be held responsible for factors out of their control such as a wide variation of ability within their classroom. Standardized testing falls far short of "a good measurement of performance", and also encourage teachers to prepare for test questions rather than teach their students concepts that they think are important. Limiting a teacher's creativity in lesson planning can't be a good thing. Some students get good grades that are no fault of the teacher and some students get bad grades that are no fault of the teacher, possibly due to situations at home, other factors such as a dangerous learning place, a learning place with a lack of adequate materials, etc.

So, in response to Vernon, there is no reasonable formula. Such a thing does not exist and it is ridiculous to suggest that the same teacher might be able to make 50,000 one year and 35,000 the next year because of factors outside that teacher's control. My mother worked in the Baltimore city school system about 20 years ago, where she received numerous threats, had her car tires slashed, and eventually quit and went to work in the private school system. Should she have been paid poorly because she had many students that didn't wish to learn, even though she made her …

BestJewSinceJC 700 Posting Maven

Adding an action listener to something just means that when some action occurs on it (such as clicking a button), the actionPerformed method will be called. So whatever code is in the actionperformed method will be executed if you, for example, add an action listener to a JButton then click on that JButton.

BestJewSinceJC 700 Posting Maven

You declared the variable courses from within the method collectCourseInformation. Therefore it doesn't exist outside of that method. Read about variable scope in Java.

BestJewSinceJC 700 Posting Maven

Thanks for the advice Chris. One more question for anyone:

http://www.malwarehelp.org/ave-exe-a-multiple-rogues-in-one-trojan-fakerean-2010.html

Does anyone know if the advice given there is legitimate, and if the programs "MalwareBytes" and "CCleaner" are legitimate? The registry file provided there means nothing to me as well.

Thanks

BestJewSinceJC 700 Posting Maven

It gets the current thread of execution then tells that thread to sleep for 10000 milliseconds which is 10 seconds. Beyond that I don't know the details, why don't you look into it and let us know what you find.

BestJewSinceJC 700 Posting Maven
Node temp = head; //head is the first node

//temp is now the last Node, head is still the first node
while (temp.next() != null) temp = temp.next();

..

BestJewSinceJC 700 Posting Maven

I have thought about it, I need to add 2 queues to the packing >>machines because it has to store the food, do I need a queue or is an ArrayList fine?

Use Java's Queue class. An ArrayList is not the same thing as a queue; a queue is a special type of list where the first item added to the list is the first item taken out of the list. So you could use an ArrayList, but you would have to make sure to remember which item's turn it was. Instead, make life easy - use Queue.

The thing I dont understand is, how am I going to add the 10 seconds timer (10secs to pack a food).

Thread.getCurrentThread().sleep(10000);

Also how is it going to find which has the shortest queue? the .size method right?

Yes.

However, once this is done how will it just pick a food from the processing queue and add it to the packing machine queue/arraylist. One it is added, then somehow it will tell the packing machine and the processing machine queue will go down by1.

Use the Queue class methods. In particular, the remove() method removes the next item and returns it. So you could do something like this:

//Up here you declare your Queue Objects..
//Find the smallest list .. 

packingMachineQueue.offer( processingMachineQueue.remove() );

I am a beginner in java, so if I have made a lot of mistakes, please understand.

BestJewSinceJC 700 Posting Maven

You can do a lot of cool things in swing but its best to try out some examples rather than wading through pages of explanations. http://java.sun.com/docs/books/tutorial/uiswing/components/button.html

BestJewSinceJC 700 Posting Maven

My sister has a windows vista machine and I have a windows 7. I want to connect remotely to her machine because she has a viruses, and I helped her track it to 'ave.exe' which is some trojan that edits registry values, starts itself when you start another process, won't let you open System restore, etc.

What software can I use to connect remotely? I couldn't figure out how to use "Remote Desktop Connection" - the one that ships with Windows. Both my sister and I have "allow remote connections" enabled through our System, but I don't know how she can set up her PC so that I can connect to her, despite reading a tutorial on it. Also, if anyone knows this information, I know her IP address via "ipconfig" so connecting that way is preferable (if it is possible).

Thanks

BestJewSinceJC 700 Posting Maven

I enjoyed Slumdog Millionaire, it was emotional in some parts, although I doubt it will be life changing or anything like that...

BestJewSinceJC 700 Posting Maven

So, let me guess, an IP check will show that you're the same exact user as "help_please"? Since what you just asked is the same question he has asked (and I have answered) in two different threads.

BestJewSinceJC 700 Posting Maven

http://www.daniweb.com/forums/thread274782.html

What is it about the help I gave you in that thread that is insufficient? I gave you code examples, detailed explanations, etc. It seems like you want someone to do your project for you. To do your project, you need to know the following:

Classes, methods, a very basic understanding of Java Generics, how to use Iterators, how to use the equals() method (you don't need to know how to implement it though, but it might help if you read up on it), a basic understanding of how to use the Scanner class or how to otherwise read in from a file. I suggest you get started on reading the Sun Microsystems (now owned by Oracle) Java tutorials.

Oh, and as your incorrectly defined LinkedList (from your previous thread) showed me, you also need to read about variable scope. You can't declare a variable inside a for loop and expect it to exist once the loop finishes. What exactly have you been learning in class all this time?

BestJewSinceJC 700 Posting Maven

To search a LinkedList you need to use an Iterator. To code an Iterator type "iterator java" into google and read things. To see if one String is equal to another String, use the code I already gave you. In your case, since your 'toWord' is inside your Word class, you'll need to create a getter method that returns the variable. Again, use google if you don't know what a getter method is.

If you simply combine the two ideas I just presented to you, you will easily be able to implement my suggestion.

BestJewSinceJC 700 Posting Maven

Every time you read in a new word from the file, before creating a new Word object, you should search your LinkedList to see if the word is already in it. If it is already in the LinkedList, then you would just add one to the word's count. If it isn't already in the LinkedList, then you should create a new Word Object with a count of 1.

BestJewSinceJC 700 Posting Maven

What I told you earlier about the Record constructor doesn't follow your teacher's directions. Your teacher wants a constructor that accepts one String as a parameter, where the String is the file name. Keep reading and you'll see.

Scanner file = new Scanner(new File(yourTextFilePathname));
OrderedList list = new OrderedList();
while (file.hasNext()){
String word = file.next();
Record rec = new Record();
rec.lookup(word);
}

In your lookup method, it should search through the file using a Scanner and every time it sees the word you're looking for (the one that was passed into the method) it should record the line number and it should also add the line it was seen on to an ArrayList. That part will be a little tricky since if you use the next() method, you aren't going to know which line number you're on. More resources you can look into for figuring out which line words are on:

Scanner class's nextLine() method which will help you read in an entire line. Then, on that line, you can create another Scanner to look through that line using the Scanner class's next() method. So in summary to write your lookup method do something like this:

public class Record{
String word;
ArrayList<Record> list = new ArrayList<Record>();
String filename;

public Record(String fname){
filename = fname;
}

public void lookup(String wordWanted){
//Create a Scanner (using the filename) to read line by line

/* while the file has another line{
1. String line = read in the whole next line …