i'm not sure. I was only following what the book did for the coding.
hrm okay I see what you mean.
This is the first java class I've ever taken and the last lol. It's a strange requirement...
Type: Posts; User: nepperso
i'm not sure. I was only following what the book did for the coding.
hrm okay I see what you mean.
This is the first java class I've ever taken and the last lol. It's a strange requirement...
so my 3 problems for the assignment were:
• a method returning the book with the lowest price in the library
• a method searching the library for Books of a given author and returning an ArrayList...
ahh so take out the arraylist comment since i already have it but keep the results and make it price!
though i had to add in the bs. for it to work- works correctly now too! YAY!!!
String Price...
so if i fix it to
String Price = JOptionPane.showInputDialog(null,
"Enter a Price ");
System.out.println("The search results for "+Price
+" are: ");
...
Okay now I am trying to do the client test for it.
I have
public static void main(String[]args)
{
BookStore bs = new BookStore();
String keyword =...
i figured double cause that's what i have for the price in the class:
package natashaepperson_chapter_09_exercise_94;
public class Book {
private String title;
private String author;
private...
lol. I'm just copying what was written in the book, than doing what the question says i'm to do.
• a method returning the book with the lowest price in the library
• a method searching the...
when i change that it causes the arralist trimtosize to give an error:
library.trimToSize();
}
says can't find it
--- Update ---
what would be better to use do you think?
So instead of saying
private ArrayList<Book> library;
write it as
private List<Book> library;
library = new ArrayList<Book>();
Actually - wait ? i think it should be this?
public ArrayList<Book> searchForPrice(String searchString)
{
ArrayList<Book> searchResult = new ArrayList<>();
//converts search string to...
i just want to make sure I did this correctly. Does it look right?
/** a method returning an ArrayList of Books whose price is less than a given number
* @param searchDouble
* @return
*/...
no gave me the same error lol
and I should change it where i have numOfhits with i to r? on the client or the class?
Like so? :
/*
62. Write a class encapsulating the concept of statistics for a baseball
team, which has...
so instead of having it be [i]? have it be like [r]?
how would you suggest to fix it?
2501
i am not sure why it's exceeding the elements, it should be right
it's saying here:
public String toString()
{
String returnString="";
for(int i=0;i<numOfhits.length;i++)
...
sorry, didn't copy the right thing
haha DUH
Thanks :D
--- Update ---
Okay My Client is now correct:
import java.util.Arrays;
/**
I've got my client and my class.
My class seems to be okay, at least on the written part i'm not getting any errors.
import java.text.DecimalFormat;
public class EncapTest {
public static...
Okay, how does this look now? I'm adding more to the code
package natashaepperson_chapter_08_exercise_63;
import java.util.Random;
/**
*
* @author Natasha.Epperson
*/
public class...
I think I understand, I get a little lost in some of the naming conventions. I haven’t had as much time to devote to java as I’d like to since I’m taking Calc III at the same time.
public class...
I'm trying to tackle the problem step by step. What I am having trouble is where to start lol
I started with writing the constructor but not sure if i'm going in the right direction for this...
I have the following code which has no errors when i run it:
/*
* 63. Write a class encapsulating the concept of the weather forecast, assuming
* that it has the following attributes: the...
awesome okay thanks !
ahh okay. no i hadn't used a driver class to test it. I wasn't sure how to do that yet I mean i know how to use import java class method and use main () methods. But not sure how to call a class i...