Results 1 to 4 of 4
  1. #1
    mrandredparis is offline Member
    Join Date
    Jan 2017
    Posts
    1
    Rep Power
    0

    Default First Program, any suggestions or corrections?

    Hi

    this is a first program, could I get any corrections or suggestion?

    /**
    * @author
    * @version 1.0
    */
    public class Book
    {
    private string title; // Tho book title of this book is Harry Potter
    private string authourFirstName;// JK
    private string authourLastName;// Rowling
    private int totalISBN; // The total ISBN is 10000
    private int theYearPublished; //1998



    public Book () {}

    /**
    * @param theTitle the title of the book
    * @param theAuthourFristName the first name of the authour
    * @param theAuthourLastName the last name of the authour
    * @param theISBN total number of inclusive
    * @param theYearPublished the year the book was published
    */
    public Book(String theTitle, String bookAuthourLastName, String theAuthourFirstName, int ISBN, int theYearPublished,){

    if(thTitle != null && theTitle.length () > 3)
    {
    title = theTitle;
    }
    else
    {
    title = "Harry Potter"

    }

    if(authourLastName != null && !authourLasName.equalsIgnoreCase("Rowling"))
    {
    lastName = authourLastName;
    }
    else
    {
    lastName = "Rowling";
    }

    if(authourFirstName != null && !authourFirstName.equalsIgnoreCase ("JK"))
    {
    firstName = authourFirstName;
    }
    else
    {
    firstName = "Rowling";
    }

    if(theISBN <20001 && >1999)
    {
    ISBN = totalISB;
    }
    else
    {
    ISNB = 1;
    }

    if(theYearPublished < 1998)
    {
    System.out.println("You cannot have less than the year 1998");
    yearPublished = 1998;
    }
    else
    {
    yearPublished = theYearPublished;
    }
    }
    }

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    5,908
    Rep Power
    10

    Default Re: First Program, any suggestions or corrections?

    Well, I doubt that you compiled and ran it because you have syntax a error in here.

    Java Code:
    if(theISBN <20001 && >1999)
    {  
          ISBN = totalISB;
    }
    else
    {   
         ISNB = 1;
    }
    But assume it did run. Does it make sense to default to a title like "Harry Potter" but then accept say
    Robert Heinlein as an author?

    In the future, please wrap your code in code tags. See BBCodes for more details.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    benji2505 is offline Senior Member
    Join Date
    Sep 2014
    Location
    MA, USA
    Posts
    265
    Rep Power
    3

    Default Re: First Program, any suggestions or corrections?

    Where shall the program start? Are you missing an entry point?
    Last edited by benji2505; 01-28-2017 at 07:14 AM.

  4. #4
    cronnin is offline Member
    Join Date
    Jan 2017
    Posts
    38
    Rep Power
    0

    Default Re: First Program, any suggestions or corrections?

    string > String
    comma at the end of overloaded constructor
    theTitle spelling error in IF condition
    semicolon after "Harry Potter"

    and many other spelling mistakes ..

    What was this program supposed to do? Where does it take data from? Seems like a poor choice for the first program.

Similar Threads

  1. My first Java Program Opinions, Suggestions...
    By fredlo2010 in forum New To Java
    Replies: 10
    Last Post: 01-13-2014, 05:00 PM
  2. Project Suggestions!!!
    By bankoner in forum New To Java
    Replies: 12
    Last Post: 10-11-2013, 08:39 PM
  3. Any Suggestions???
    By Coulterce in forum Forum Lobby
    Replies: 1
    Last Post: 06-29-2012, 06:38 PM
  4. Looking for suggestions
    By tonino in forum New To Java
    Replies: 5
    Last Post: 09-26-2010, 07:17 PM
  5. any suggestions?
    By PureAwesomeness in forum New To Java
    Replies: 4
    Last Post: 01-19-2009, 08:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •