HELP please.. Very simple, but I can't do it...

Hi,
How can i make and int be between 1 and 10? I'm using bluej. So I'm declaring the variable enjoyability as an int and then starting directly in the constructor like:
public class Book
private String author;
private String title;
private String cost;
private String numberOfPages;
private int enjoyability;
private String genre;
public Book(String author, String title, String cost, String numberOfPages, int enjoyability, String genre)
this.author = author;
this.title = title;
this.cost = cost;
this.numberOfPages = numberOfPages;
this.enjoyability = enjoyability;
this.genre = genre;
public String author()
return author;
public String title()
return title;
public String cost()
return cost;
public String numberOfPages()
return numberOfPages;
public int enjoyability()
return enjoyability;
public String genre()
return genre;
public void print()
System.out.println("\n############ LIBRARY ############");
System.out.println("----------Book Details-----------");
System.out.println(" Author: " + author() );
System.out.println(" Title: " + title() );
System.out.println(" Cost: " + cost() );
System.out.println(" Number of pages: " + numberOfPages() );
System.out.println(" Enjoyability: " + enjoyability() );
System.out.println(" Genre: " + genre() );
and then I have another class that stores the book I made and print it to the console:
public class Library
private ArrayList items;
* Constructor for objects of class Library
public Library()
items = new ArrayList();
public void addBook(Book newBook)
items.add(newBook);
public void alphaAdd()
public int numberOfItems()
return items.size();
public void print()
for(Iterator iter = items.iterator(); iter.hasNext(); ){
Book book = (Book)iter.next();
book.print();
System.out.println();
How can i limited it to be between 1 and 10?? Thanks

public class Book
private String author;
private String title;
private String cost;
private String numberOfPages;
private int enjoyability;
private String genre;
public Book(String author, String title, String cost, String numberOfPages, int enjoyability, String genre)
this.author = author;
this.title = title;
this.cost = cost;
this.numberOfPages = numberOfPages;
this.enjoyability = enjoyability;
this.genre = genre;
public String author()
return author;
public String title()
return title;
public String cost()
return cost;
public String numberOfPages()
return numberOfPages;
public int enjoyability()
return enjoyability;
public String genre()
return genre;
public void print()
System.out.println("\n############ LIBRARY ############");
System.out.println("----------Book Details-----------");
System.out.println(" Author: " + author() );
System.out.println(" Title: " + title() );
System.out.println(" Cost: " + cost() );
System.out.println(" Number of pages: " + numberOfPages() );
System.out.println(" Enjoyability: " + enjoyability() );
System.out.println(" Genre: " + genre() );
and then I have another class that stores the book I made and print it to the console:
public class Library
private ArrayList items;
* Constructor for objects of class Library
public Library()
items = new ArrayList();
public void addBook(Book newBook)
items.add(newBook);
public void alphaAdd()
public int numberOfItems()
return items.size();
public void print()
for(Iterator iter = items.iterator(); iter.hasNext(); ){
Book book = (Book)iter.next();
book.print();
System.out.println();
}

Similar Messages

  • I'm ready to help the FOSS community , but I can't find a proyect.

    I've been working as a C# developer for the last 5 years and using linux for about the same time. One of my goals for the 2011 is to start developing FOSS in my spare time. Maybe in python, I find it interesting.
    However , there are some problems that I am facing:
    1) The proyect: every proyect I found is too big , or too complex , or too boring. Maybe I'm missing something , maybe I'm looking in the wrong place. I don't know , Exaile was the closest to a interesting proyect that I found , but after reviewing the code , I couldn't understand the gstreamer logic (I mean , that's the core of the app , right?).
    2) My "coworkers": I'm used to work everyday in the same office and and have a close relationship with them. I don't know how to react to this change and how does the other developers could/would react to a new developer coming to the proyect (I mean , "hey guys , i fixed these bugs and added the 2 things for the next milestone. Btw , I'm Andres" seems wierd lol).
    I think I'm not the first one having these problems , so any feedback would help me.
    Thanks

    nagel wrote:I'm ready to help the FOSS community, but I can't find a project.
    How exciting! I love helping FOSS projects, but it can be difficult to decide what to do.
    nagel wrote:One of my goals for the 2011 is to start developing FOSS in my spare time. Maybe in Python, I find it interesting.
    I agree, Python is very interesting. I made my first Python application a few months ago. It was easy to use, fun, and I think using Python helped me to become a better C programmer.
    Keep it simple
    nagel wrote:Every project I found is too big, or too complex, or too boring. Maybe I'm missing something, maybe I'm looking in the wrong place.
    My suggestion: choose a project where you need to learn one thing at a time.
    There are languages (examples: Python, C), libraries (examples: GTK, Qt), and programming paradigms. (examples: GUI programming, threaded programming) When you begin working on a project, you will probably need to learn something new. Try to learn only one thing at a time. For example, if you have to learn gstreamer and GTK (two libraries) at the same time then you might become frustrated. Or, if you have to C++ and Qt (a language and a library) at the same time then you might become frustrated.
    So, try to learn one thing at a time.
    Other FOSS developers
    nagel wrote:I'm used to work everyday in the same office and and have a close relationship with them. I don't know how to react to this change and how does the other developers could / would react to a new developer coming to the project.
    I love working online with FOSS developers! It feels like I'm talking to a celebrity. You know, like when Allan or Dusty posts a reply to me on the Arch Linux forums.
    Of course, you should join the mailing list and bug tracker for the project you want to work on. I don't usually introduce myself. Instead, I just start helping, and people will know me soon.
    My FOSS experience
    Here are some examples from my FOSS experience.
    Many years ago, I wanted to write a new FOSS application. I couldn't think of any new applications to make, so I decided to make a video game. There are NEVER too many video games.
    I learned many things by making video games:
    Languages: C, Objective-C, Java, Assembly, Ada
    Libraries: Allegro, SDL, Java SWING
    I've submitted many bug reports to many different projects, such as wxWidgets, Allegro, Udiskie, and Haiku. I really like submitting bug reports and working with the developers to fix the problem. It's easy to do and I get to use better software.
    I maintain some AUR packages. (very easy, but it helps FOSS)
    I helped write the documentation for some software from the Arch Linux community, such as Packer and Udiskie. I've contributed to the Arch Linux wiki.
    Recently, my wife and I wanted a new application for budgetting. I decided to write one. I used Python and wxWidgets. It works pretty well. My next goal is to convert it to C++ and wxWidgets, and then make a version for Haiku using C++ and the Haiku API.
    Interesting things
    You should definiteley work on something that you think is interesting. To me, that's Arch Linux, Haiku, bug reports, and documentation. Try to find things that are interesting to you!
    Lastly, don't make your goal too big and don't try to do too much. There are many many people helping in FOSS. If everyone does a little bit, then we can make something great.

  • Making a join seems simple but I can't get it to work

    Hi All,
    I have 2 tables LUGallery and LUSubGallery, the tables are related by the GalleyID field
    LUGallery
    Gallery ID
    ClientID
    GalleryName
    5
    50
    Australia
    8
    50
    Weddings
    12
    33
    Portraits
    4
    33
    Landscapes
    LUSubGallery
    SubGalleryID
    GalleryID
    GalleryName
    67
    5
    NSW
    68
    5
    QLD
    69
    8
    Reception
    70
    8
    Location
    87
    8
    Ceromony
    97
    4
    Rain Forest
    What I am try to do seems simple but I can't get it to work the way I want it.
    I am trying to write a query to display Galleries from the LUGallery tbl that have a Sub Gallery attached to them (ie. It's GalleryID appears in the LUSubGallery tbl)
    So the query for the above example would list Australia, Weddings & Landscapes
    I have tried to write code both with inner joins and nested queries but just can't get it right,
    Any help would be greatly appreciated.
    Thanks in advance
    Kris

    I just want to
    display the GalleryNames from the LUGallery tbl once
    Then you probably do not want include all the extra columns from the LUSubGallery table.
    It returns all of the records from both tables that Have
    the same GalleryID
    That is the way this type of JOIN works. It will return one record for each matched GalleryID. If you only want to display the unique gallery names you can either:
    1) Use an EXISTS clause.  It will return the distinct records from the main gallery table IF a matching record exists in the LUSubGallery table
    --- Not tested ---
    SELECT  LUGallery.GalleryID,
    LUGallery.GalleryName
    FROM    LUGallery
    WHERE   EXISTS (
            SELECT  *
            FROM LUSubGallery
            WHERE LUGallery.GalleryID = LUSubGallery.GalleryID
    http://www.techonthenet.com/sql/exists.php
    ... OR ....
    2) Use the DISTINCT operator to return only the unique combinations of the selected columns. Note: DISTINCT considers all columns in the SELECT list . So if you only want unique galleries, do not include the LUSubGallery columns in the SELECT list.
    http://www.w3schools.com/SQl/sql_distinct.asp
    Message was edited by: -==cfSearching==-

  • My iPhone has an option for a Vietnamese keyboard that works very well but I can get my MacBook Pro to work the same way.  Why is that?

    My iPhone has an optio for a Vietnamese keyboard that works very well but I  can't get the same results on my Mac Book Pro.  Why is that?  Am I typing some thing wrong?  There are no pop-ups when I use the Vietnamese keyboard on my laptop or desktop.

    MacBook Pro
    https://discussions.apple.com/community/notebooks/macbook_pro
    https://discussions.apple.com/community/mac_os?view=discussions 
    http://www.apple.com/support/macbookpro
    http://www.apple.com/support/iphone

  • Can only connect to Linksys E4200 when very close but PCs can connect at 50 feet. What's the solution?

    Can only connect to Linksys E4200 when very close but PCs can connect at 50 feet. What's the solution?

    If you're technically comfortable in getting to your Linksys settings - try changing the network mode or channel in your router's settings.
    I still use my old Linksys router and when it's set to the default channel, which is 7, my Macbook Pro and Macbook Air sometimes have issues - changed the channel to 9 and have had no issues since.
    Maybe it might work for you.
    In any event - screenshots below are for your E4200 and play with those settings and see if any of the changes you've made improves how your Macbook connects.  Before you change any settings, just remember what the old settings are in case you need to go back to your old settings.
    Good luck.

  • Please Help! A simple question I can't seem to find the answer to.

    Ok so this is probably something really easy but I can't for the life of me get it to work.
    I got a new Macbook Pro recently and have been building up a new library with my older songs and newer ones I've acquired since the purchase. My problem is when I go to sync my Ipod to the new Mac my ipod automatically goes to the "ok to disconnect" screen without syncing anything. I pressed "sync" and "transfer purchases" and it still goes into disconnect mode, very quickly too.
    Its almost as if the ipod is protecting itself and dosen't want to sync to the new Mac for that reason, but that's what I need it to do. Its a 'Mac to Mac' move so its not like I'm putting a Mac ipod into a Windows computer.
    I've looked everywhere for answers but all I can find is troubleshooting for 'Mac to PC' solutions. No one seems to have answers for the seemingly much easier counterpart.
    What do I have to do, or how do I get to a setting that would let my ipod sync successfully on this new laptop? If anybody could help it would totally save the day.
    The ipod is an iPod classic 2008-09 120gb

    If other apps are working it must be a problem with the Pac12 app. You need to contact their developers.

  • Everytime I get on a video chat i can here the person very well but they can't here me what can I do to fix this I have droped my iPod in water and also droped it and cracked it but it still works fine what should i do. Please respond ASAP!!!!!!!!

    Everytime I get on a video chat  I can here the person I'm chating with but they can't here me at all . Now I have droped it in water and my ceral and I have droped it in the street . But it's still working fine but running a little slow too. What can i do resond ASAP!!!!!!!!!

    Have you tried here:
    iOS: Not responding or does not turn on
    You can check your warranty coverage by entering the SN here:
    Apple - Support - Check Your Service and Support Coverage
    For how to get warranty work see:
    Apple - Support - iPod - Service FAQ
    The fastest is to make an appointment at the Genius Bar of an Apple store.

  • Web pages content looks very "simple" but looks normal with IE/GC?

    Computer is running Windows 7.. with the latest firefox version. Not sure what is causing this but when I log onto Facebook, banking sites, craigslist - everything looks very simple as if there is no page layout or graphics. Some pages look more simple than others but no website seems to load properly. I've checked that the page style option isn't checked on "No style" already.
    I tried to take a screen shot of what FB looks like when I log on.
    *http://i84.photobucket.com/albums/k40/naughtykobra/fbpage.jpg
    Seemed to notice the change after a Java update - so I did a system restore to before that update with no luck.
    Loaded the same websites on Google chrome and everything works fine!?

    Hi,
    You may also have to make sure that '''Allow pages to choose their own colors, instead of my selections above''' is selected in '''Tools''' ('''Alt''' + '''T''') > '''Options''' > '''Content''' > '''Colors'''. [https://support.mozilla.org/en-US/kb/Options%20window%20-%20Content%20panel Options > Content]
    [https://support.mozilla.org/en-US/kb/Options%20window Options]
    If the problem persists, please also try a [https://support.mozilla.org/en-US/kb/Managing-profiles new profile]. You can later [https://support.mozilla.org/en-US/kb/Recovering%20important%20data%20from%20an%20old%20profile?s=profile&r=1&e=sph&as=s copy the personal data] from the previous profile to this. Firefox stores the personal settings and data separate from its [http://kb.mozillazine.org/Installation_directory installation and files].
    [https://support.mozilla.org/en-US/kb/Profiles?s=profile&r=2&e=sph&as=s Profiles Howto]
    [http://kb.mozillazine.org/Profile_folder_-_Firefox Firefox Profile Folder & Files]

  • Very simple, but not working Table to Flat File

    I'm new to ODI, but I am having too much difficulty in performing a very basic task. I have data in a table and I want to load the data to a flat file. I've been all over this board, all over the documentation, and all over the Googles, and I can not get this to work. Here is a run down of what I have done thus far:
    1. created a physical schema under FILE_GENERIC that points to my target directory
    2. created a logical schema that points to my new physical schema
    3. imported a test file as a model (very simple, two string columns, 50 chars each)
    4. set my parameters for my file (named columns, delimited, filename resource name, etc.)
    5. created a new interface
    6. dragged my new file model as the target
    7. dragged my source table as well
    8. mapped a couple of columns
    9. had to select two KMs: LKM - SQL to SQL (for the source) & IKM - SQL to File Append (for the target)
    10. execute
    Now, here is where I started hitting problems. This failed in the "load data" step with the following error:
    +7000 : null : java.sql.SQLException: Column not found: C1_ERRCODE+
    I found a note on the forum saying to change the "Staging Area Different From Target" setting on the Definition tab. Did that and selected the source table's schema in the dropdown, ran again. Second error:
    +942 : 42000 : java.sql.SQLException: ORA-00942: table or view does not exist+
    This occurred in the "Integration - insert new rows" step.
    The crazy thing is that in a step prior to this ("Export - load data"), the step succeeded and the data shows up in the output file!
    So why is ODI trying to export the data again? And why am I getting an ORA error when the target is a file?
    Any assistance is appreciated...
    A frustrated noob!
    Edited by: Lonnie Morgan (CALIBRE) on Aug 12, 2009 2:58 PM

    I found the answer. But still not sure why this matters...
    Following this tutorial, I recreated my mapping:
    [http://www.oracle.com/technology/obe/fusion_middleware/ODI/ODIproject_table-to-flatfile/ODIproject_table-to-flatfile.htm]
    I was still getting the same error. I reimported my IKM and found that the "Multi-Connections" box was unchecked before and now it was checked. I may have unchecked it in my trial & error.
    Anyway, after running the mapping again with the box checked, the extract to a file worked.
    So, I'm happy now. But, I am also perturbed with the function of the this checkbox and why it caused so much confusion within ODI.

  • Help please: deploying simple flex application

    I developed a very simple flex application with simple
    components. No data base involved, neither java or cold fusion. I
    never hosted a website before. I want to host this application. Can
    someone guide me if there a service available to host a flex
    application. And steps involved. I appreciate anyone who help me
    out here. I need to get this done asap.
    Thanks.

    Put the compiled swf and its html wrapper code in an url
    accessible folder. Hit the url.
    That's it.
    Tracy

  • Very simple but practically? any one?

    hey friends,
    i  have a simple questions..for u all before giving answer plz any one check once practically and gve me answer.i want to have a field in one table of currency type where i can give ruppes or dollars along with paise and cents...
    example..5 rupes 20 paise...
    10 dollars 40 cents..
    10.40 $
    i tried with currecny along with reference field cuky..
    curr is for money and cuky is for whcih currency..type i.e. which type of currency is useful..? i ahve tabken as total 10 in currency 10 8 for normal and 2 for decimal ok
    plz help me as earley as u can friends..ok..

    Hi satish,
    look at the main financial items database table BSEG.
    Use the data elemet WRBTR for the amount in document currency, give a reference to the curreny key defined with data element WAERS.
    Every thing will be fine if, at the time of input and output of the field in screen or list field, the refernce is established.
    Don't worry if what you see in debugger looks different. For historical reasons, currency amounts are handled and stored in packed decimal fields with 2 decimals. The referenced currency key will determine the number of decimals used for input/output and calculations. The information is stored in the respective TCUR* tables of the system.
    Regards,
    Clemens

  • HELP PLEASE!!! HOW CAN I INSTALL iChat AV??? This is taking forever!!

    My problem is a lot more complex than it sounds and I would appreciate any help I could receive. I am using a 1.8GHz PowerPC G5 running Mac os X 10.4.10.
    I used to have iChat on my computer, but it does not work anymore. So, I have tried looking for a way to download it online, but could not find anywhere. So, I used the software installation disks on my computer to try and install ichat. It says it has installed, and when I open it up it prompts me with questions to set it up. Here is my problem though: I can't get through the start up process and actually use ichat, as whenever I click anything the start up application freezes (little purple circle that svivels comes up). So, I can't get ichat to work. any suggestions? ~Thank you

    Some applications require that you have the BSD Subsystem software installed on your computer. The BSD Subsystem is installed by the Mac OS X Installer, but you can choose to not install it. If you did not install this software, you need to reinstall Mac OS X and make sure the BSD Subsystem is selected in the Custom Install pane of the Installer. Reinstalling Mac OS X does not affect your settings unless you choose to erase and install.
    MacBook Pro 2.33 GHz Intel Core 2 Duo   Mac OS X (10.4.10)   3 GB 667 MHz DDR2 SDRAM

  • Got  a macbook pro aboute a month ago and it has started buzzing on the left hand side its not very loud but yae can noyice it is this a problen or do they all do this

    got a buzzing noise from the left side ov this macbook pro only had it bout a month is this normal or should i get it checked out ?

    it does it with and without the charger its like a sif wun ov the fans are broke yae can hear it as soon as its turned on. its noy affectin the computer but u can hear the buzzin in the backround

  • Help please! UD connect datasource can not stay in synch with source table

    I have been using UD connect to extract data from Sybase table views for 2 years already. As many who have used UD connect know it is very diffcult to get it to work. But I went through all that and at least it has been working fine except sometimes difficulty transporting. And I am aware of  all major OSS notes about UD Connect.
    However this loading error has been driving me crazy. Almost on a daily basis some data loads would fail with error 'DataSource (datasource name) has to be replicated '.
    So I re-generated the datasource and activated infosources, test loaded and it all worked fine. Come next morning it  would fail again with the same error.
    I talked with DBAs and they swear that no table changes were made overnight. then after it keep happening for several days in a row, I ruled out table change possibilities. Especially when I read this morning the error message:
    DataSource (datasource name) does not have the same status as the source system in the Business Information Warehouse.
    The time stamp in the source system is 2007.05.01 17:40:59.
    The time stamp in the BW system is 2007.05.01 17:39:45.
    The timestamp is only less than 2 minute apart.
    Can anyone give me any pointers?
    I now have a production support problem everyday.
    Any help is greatly appreciated!
    Julian

    I am in need to automate the UD Connect process in SAP BI. I am trying to push the data on daily load basis from SQL Server 2005 to SAP BI. I was told to use UD Connect due to some restrictions.
    Could you plz let me know how I can automize the UD Connect process. I have a minimum experience configure the RFC destination etc. But that is not enough to go and start the process.
    First I wanted to know how the view will be taken it to SAP BI?
    Before the view is moving to SAP BI, will the UD Connect converts the view into Flat file and then transfers to SAP BI?
    If it converts to flat file, where will it be stored in SAP BI? Is it stores in Application directory of the BI server or something else?
    If it not converts into flat file, then how can I automate this process on daily load basis, for this should I write any ABAP program? If yes, please let me know the pseudo code how I can do it?
    I am really confusing about the daily load basis.
    It would be highly appreciated if you let me know the process.

  • Help please - Updating .jar file and can't compile decompiled .java files.

    Ok, so there is a game on the internet called 'runescape', its a java applet that runs in the web browser from a cache in the windows directory.
    Basically im trying to edit this client so that i can run it away from their website (for use on a private server).
    The problem i am getting is that when i decompile the class files from the .jar into the .java files i can't recompile the .java files.
    E.G. I decompiled one of the .class files and tried to re-compile it agian straight away which brought me errors, i did this to rule out my editing as the problem.
    The jar file can be found [here.|http://world80.runescape.com/loader_gl397188536.jar] but the link will no double be dead after a few weeks.
    Can somebody please take a look and help me? I'm fairly new to java programming so if you could keep your answers as simple as possible that would be great, thanks.
    Ps. If this is the wrong section im sorry, i couldn't find the right section and this section seemed closest for me.

    i'm compiling using the javac command in a batch file, its displaying 100 errors but there are more, it seems to be showing that the syntax is incorrect as it is labeling brackets as being in the incorrect places.
    Decompiling error?
    As for being allowed to do this, im not so sure the company would approve but im only doing this for learning purposes and will not be releasing any of it upon the internet.

Maybe you are looking for

  • ITunes and Quicktime disapears!

    Okay. This is driving me insane! Late last year iTunes decided to stop working right. I would click the desktop icon like I normally do and then iTunes would appear on the screen for no more than 2 seconds before disapearing. I uninstalled and reinst

  • I have purchased adobe creative suit 3 and installed in my pc. my pc crashed and i tried installing the product in other pc. my serial  number doesnt work anymore. what is the solution

    i have purchased adobe creative suit 3 and installed in my pc. my pc crashed recently and i tried installing the product other pc. my serial  number doesnt work anymore. what is the solution

  • Linking the views

    Hi, i am facing a problem while linking two views in the bsp application (under the same controller). i am using the anchor tag <a> for the hyper reference, because i have to link the views through hyper reference only, can anyone please tell me the

  • Cover Flow , bad preview for jpg

    the most of my pictures are .jpg and for the most of them, Cover Flow create bad resolution preview . do I move a picture to a other mac with 10.5.2 installed, the preview in Cover Flow is fine ! for me seems to be a cache problem. some one knows whe

  • Capacity availability check

    Hi All, I need to check the capacity availability for a person who assigned to workcenter which is assigned to the activity in the network. I maintained the cap.planning profile for network order type. I have created 2 activity under the same network