Jump to content

super_teabag

Member
  • Posts

    186
  • Joined

  • Last visited

Everything posted by super_teabag

  1. @Midnight @madknight3 @Ghost Thanks for all the help. that "isEmpty()" method is awesome I didn't know it existed as part of the arraylist library. I got the errors worked out, and the method works now. Thanks for the help guys!
  2. yeah i've tried that first, and i knew that the first index starts at 0. Such as itemsheld.get(0) will return the first indexed item. i've also tried ItemsHeld.size()=0 in my if statement, but here's the error i keep getting. at java.util.ArrayList.rangeCheckForAdd(ArrayList.java:612) at java.util.ArrayList.add(ArrayList.java:426) at Game.show(Game.java:218) at Game.main(Game.java:269)
  3. Having a bit of trouble with this method that i'm trying to create a method for a project. public void show (){ String result = ""; if(ItemsHeld.get(1)==null){ msg = "The player is not holding anything."; } else{ for(Item objects: ItemsHeld){ result += objects.getName()+ " "; } msg = "You are holding " + result; } } This method is designed to check if there's items in a player inventory. The Item has 3 methods in it's class "getname()" returns the name of the object. getLongdescription() which returns the long descriptions of the item. and getweight() which gets the weight of the object as an integer. The items are stored in an arraylist called "ItemsHeld". At this point in time there's nothing in the arraylist of Items. There's two scenarios that could happen one you can return all the items in the players inventory to at msg. Secondly, the player has no items in his/her inventory and returns 'you don't have any items.' The compiler is giving me an error about a null pointer, saying something about the size of the array list Idk how to check if a players inventory doesn't contain anything without some kind of error popping up.
  4. I keep posting in here for help, but I'm tryin to undertan this, and learn from what you guys/girls have to offer You're really helpful, and thanks for all the help thus far. Here's my question, I've got this class given to me by my professor and he want me to create a mehod that returns a single string that contains all the trees that can be found in the array list. initialize a local variable of the class string. Traverse the entire aray list of tres and or each one o them invoke the ethod toString() rom the class Tree. append the value returned by invoking the method to String to the String result, adding a "\n" at the end. Once the entire array list has been traversed return the String result. /** * * * */import java.util.ArrayList;//imported the java utility containing//methods called add, get, length//gives us the ability to create array lists without//creating a ton of Strings, methods of those strings//then the overcomplication of having values associated with those stringspublic class TreeDB{// instance variables - replace the example below with your own//constructor array list//created a private arraylist <type tree>//the array's name private ArrayList < Tree > db; /** * Constructor for objects of class TreeDB */ public TreeDB() { //new array list invoked they called it "db" // new array list contains a string name, the low value for height //and the db = new ArrayList < Tree > (); Tree t1 = new Tree("Pin Oak", 59, 72); Tree t2 = new Tree("White Pine",50,80); Tree t3 = new Tree("Silver Maple",50,80); Tree t4 = new Tree("Tulip Tree",70,90); Tree t5 = new Tree("River Birch",40,70); db.add(t1); db.add(t2); db.add(t3); db.add(t4); db.add(t5); } /*********************************** * to String method is supposed to return the * name of the tree as a string ********************************/ public String toString(){ String result = ""; //we need somewhere to put our result as a string //for statement must have compatible types o the array //he array I'm tryin to get the names of is db //we must invoke the method toString onto db for(String Tree : toString(db) ){ System.out.println("the name of the trees are: " + tree); } result = this_tree; return result; }
  5. Thanks alot everone! It's really helpful to me when I'm learning how to do the basics in java, and midterms are net week so I'm trying to get everything down and really kill the test. Getting a headstart on my project so that if I don't understand anything I can have lots of time to figure things out. Sorr or no usin code tags I'm a noob here on this part of the forum.
  6. *FACE BRICK* will do sir thank you @fizzlesticks
  7. Help me, trying to get a head start on this project, and I though I was doing this right. I was wrong. Can't even make a simple class called Range. the instruction say make a constructor, 2 getter methods, a range method, and the get average method. My logic is wrong on my range method, but idk why my getter methods aren't passing on the correct parameters. here's my code, also my professor provided me with a testrange program to test to see if my methods were working correctly. /** * Write a description of class Range here. * * @author (your name) * @[member='versions'] (a version number or a date) */public class Range{ // instance variables - replace the example below with your own private int low; private int high; /*************************************** * Constructor for objects of class Range **************************************/ public Range(int plow, int phigh) { //instantiated both plow and phigh as low and high //respectively. plow = low; phigh = high; } /* public void setLow(int plow) { plow = low; } public void getHigh(int phigh){ phigh = high; } */ /************************** * returns the value of Low pased by plow **************************/ public int getLow(){ return low; } /**************************** * returns the value of High passed by phigh * in the constructor ****************************/ public int getHigh(){ return high; } /****************************** * Checks is the valued passed by Plow * and Phigh between the two values. ******************************/ public boolean inRange(int value){ if(low < high){ return true; } if(high > low){ return true; } else{ return false; } } /************************ * method devised to get the average * of the instance variables passed on by pLow * aka pillow (get it?) and pHigh. *************************/ public double getAverage(){ double average = (low + high)*.5; return average; }} TestRange.txt
  8. I prefer blues for typing over browns for sure. wish they were sooooo loud though
  9. I can't speak for other keyboards, but I can tell the difference between cherry mx blues, and browns on the same type of keyboard. My brother has a Coolermaster rapid (browns) and I've got a coolermaster rapid (blues). What i find going between the two is that blues are slightly harder to press, and I like they more for the tacticle feed back. When I switch back to browns they feel mushy (best way i can describe it) and they don't have that audible sound and satisfying click. Much much more satisfying to type on. I can't speak for other keyboards however as I've not yet tried them. I would personally go for the Das keyboard if you're doing alot of typing as they seem to be centered around typists.
  10. Thanks everyone for helping out, I'm so confused on the rest of my assignment though... it's due tuesday I'm at my whits end and can't figure out how to come up with several more methods that I need to.
  11. So, I'm doing this homework about creating classes, and my own methods, and I can't figure out how to do this one portion of the instructions which says. Create a method called public void nextDay( )– advance the date one day. This may also require advances to the month and/or the year. (15pts) Note: Invoke the isLeapYear method, described below,to figure out if the year is a leap year. If it is a leap year, change the number of days for February from 28 to 29 in the String where you stored the number of days for each month. Instead of using literal numbers in your if statements to compare the number of days, use the substring method to retrieve the number of days for each month from the String that contains the days for each month, the Integer.parseInt method, and invoke the isLeapYear method when needed. I don't understand how to invoke one of my methods in an if statement. Examples: 4/10/2014 will advance to 4/11/2014 12/31/2014 will advance to 1/1/2015. 2/28/2013 will advance to 3/1/2013 2/28/2004 will advance to 2/29/2004 note that 2004 is a leap year Nextday.txt
  12. Hey guys/girls, I'm a student at Grand valley going for computer science, and I'm taking a java course this semester Right now we're covering methods, parameters, constructors, how to instance variables, and call up methods. I find it all very confusing at this point. Does anyone know of a resource that I can use to help me understand these things for my upcoming project My prof isn't giving us much hands on programming example which is how I personally learn. Any suggestions on websites that I can practice on? IDK if Lynda.com would follow my course at this time, and I'm in college working a part time job that doesn't make much. Appreciate any help you can offer Thanks! Here's a notepad doc of what we went covered in class today. java help.txt
  13. @Profquast it's up. didn't show up first time for some reason.
  14. A while back I snagged a snip of the WAN show when linus, slick, and jerry where talking about windows barnucles edition. I'm a little late to the show I just had to share it.
  15. My favorite part about the sony xperia is the keyboard, and it's aesthetics. So, many keyboards I've used recently (other than the iphone) are hard to manage and unresponsive. Sony's implementation looks responsive and well thought out. It may not seem like much, but for me when you spend alot of time, texting, searching, and emailing. A good keyboard is a must have.
  16. Hey all, just teasing the idea of getting a 3ds, 3ds XL, or a 2DS. Also, getting pokemon Y to go with it. Have any of you played through pokemon Y, and what's your impressions of the game? I havn't been in the pokemon series since pearl version. I played all the way up from gold -> crystal -> sapphire -> ruby -> and finally pearl version. I'm a little older now, but I know alot of longtime fans of the series have enjoyed this newest game. On a side note which system should I pair it with? from what I've seen the 3ds can stream netflix, and I'd definately use that feature. I'd enjoy the extra real estate that the 3ds XL has. Share your opinions! thanks
  17. Actually I get grilled chicken, no sauce, cheese only, and use a little dressing with mine. I don't get anything super bad on it. It's just when I'm hungry pressed for time and there's not many options around. Who says it's not better than a Big Mac
  18. I can't see the poll as I'm on an iPhone but my vote goes towards eating at mcdonalds once a month. If I do go I get a salad, so interpret that the way you want.
  19. @DLM_012 That's pretty much why i want to buy a 2DS LOL. Wanna play through pokemon, and use it for nostalgia. Put it on ebay I'll buy it from you haha
  20. Well, portability it don't think will be an issue I'll carry it around in my backpack and play it in between classes or on my work breaks. Having a hard time justifying it just to play Pokémon.
  21. Simple question. I'm thinking about getting a 2ds because it's cheaper than 3ds/XL to play Pokemon x and y or any other pm versions out there. I like a few other games, but I'll start with Pokemon Does anyone own a 2ds how do u like it? What's your opinion on it? And is it worth getting even for one game?
  22. @Slick How do you run different drivers on the same hardware setup? Just different SSDs? Hi all, long story short I RMA'd this sapphire radeon 7850 1gb OC edition graphics card twice... Because the first replacement card was just flat out not functional. However, I've not yet tested this 7850 that I received as of late. In the meantime I did not like my experiences with AMD, or sapphire cards. Bit the bullet for a new card that I would enjoy the performance of, and purchased an Asus gtx 760 2gb ed My question is to test to make sure my 7850 works, I've got to install it in a system. Mine currently has nvidia drivers installed. However, would uninstalling the nvidia drivers, and putting catalyst 14.1 interfere with my previous nvidia drivers? I'm going to switch cards back to my current configuration. Just wondering if changing drivers all about would cause havoc in windows 7 home premius (64bit)? Suggestions, and thought are appreciated. I'm probably going to 1) unistall nvidia's drivers 2) run CCleaner 3) install 7850/drivers 4)test card 5)uninstall catalyst 6)run CCleaner 7) install my 760 again and nvidia drivers
×