How to add constructors

here is the program I have: public class Freshman
     private String name;
     private int score;
// constructor with no parameter
public Freshman () {
     score = 0;
// constructor with one parameter
public Freshman (int newScore) {
     score = newScore;
public void setScore (int newScore) {
     score = newScore;
public int getScore () {
     return score;
public void setName (String newName) {
     name = newName;
public String getName () {
     return name;
I am supposed to add this for an assignment:
a. a private variable "double currentGPA"
b. a constructor that initializes both "currentGPA" to "0.0" and "score" to "0" as the default values
c. a constructor that initializes the variables "score: and "currentGPA" to the values assigned by callers.
What is a caller in the program?
Do I add another line that has something like //initialize constructor...?
I am very confused and would appreciate some help or maybe a direction to go to to get started.

Okay so I followed the advice and my assignments instructions and did the following:
public class Freshman
     private String name;
     private int score;
     private double currentGPA;
// constructor with no parameter
public Freshman () {
     currentGPA = 0.0;
     score = 0;
// constructor with one parameter
public Freshman (int newScore) {
     score = newScore;
public void setScore (int newScore) {
     score = newScore;
public int getScore () {
     return score;
public void setName (String newName) {
     name = newName;
public String getName () {
     return name;
public Freshman (double currentGPA) {
     currentGPA = currentGPA;
public void setcurrentGPA (double newCurrentGPA) {
     currentGPA = newCurrentGPA;
public double getcurrentGPA () {
     return currentGPA;
and then the connection program I also revised goes like this:
public class ThreeFreshman
// test class Freshman
     public static void main (String[] argc)
// call the constructor with a default value
Freshman freshman1 = new Freshman();
freshman1.setName ("Allen");
System.out.println("Your name " + " = " + freshman1.getName());
freshman1.setScore(84);
System.out.println("Your score " + " = " + freshman1.getScore());
freshman1.setcurrentGPA(3.2);
// call constructor with a value
Freshman freshman2 = new Freshman (94);
freshman2.setName ("Bob");
System.out.println("Your name " + " = " + freshman2.getName());
System.out.println("Your score " + " = " + freshman2.getScore());
System.out.println("Your GPA " + " = " + freshman2.setcurrentGPA(3.5));
// call a constructor with a value
Freshman freshman3 = new Freshman (92);
freshman3.setName ("Cindy");
System.out.println("Your name " + " = " + freshman3.getName());
System.out.println("Your score " + " = " + freshman3.getScore());
System.out.println("Your GPA " + " = " + freshman3.setcurrentGPA(3.4));
But now I am getting an error when I run it or compile that says :void type not allowed here referring to the add sign in the system.out.println of "Your score" ... GPA...
So what does that mean?
AND the other error I am gettting while compiling freshman.java is: Exception in thread "main" java.lang.NoSuchMethodError:main. What does this mean?

Similar Messages

  • How to add a class in a project?

    Hello!
    i'm a beginner in developing and i don't know how to add a class in a project in Sun Java Wireless toolkit 2.5.2...
    The name of my project is essai2 and i already put a class, LogoMIDlet and now i want to put my new class ComBasique, how can i do that?
    and do you know if there is a program for bluetooth in order to connect my Nokia 6680 to another device that have a bluetooth?
    thanks a lot for your answer!
    Sophie

    how to change the class name after the project is created.In NetBeans, right click the class name either in the declaration or constructor, select Refactor --> Rename... and follow the dialog.
    You can refactor --> rename anything that is not in a guarded block. For those, there are options via the properties window.
    db

  • How to add an image to a JPanel ?

    hi,
    do you now how to add an image to a JPanel ?
    thanks a lot !

    You can either use the Graphics method drawImage from the panel's paintComponent(Graphics g) method, or you can create an ImageIcon, with your Image in its constructor. And then create a JLabel, passing that ImageIcon in its constructor. Then, you can simple use the panel.add() method to add that JLabel.
    For using the paintComponent method, check out the thread already posted above (I'll type it in again just in case)
    http://forum.java.sun.com/thread.jsp?forum=31&thread=288769
    If you want to use a JLabel, you can do something like this:
    Image img;
    JLabel label = new JLabel(new ImageIcon(img));
    JPanel panel = new JPanel();
    panel.setLayout(new FlowLayout());
    panel.add(label);Val

  • Help! how to add a "0" infront of month?

    i am using this method to retrieve current day and month
    Calendar c = Calendar.getInstance();
    int currMonth = c.get(c.MONTH)+1;
    int currDay = c.get(c.DATE);
    int currYear = c.get(c.YEAR);
    it works well.
    but now, i want to insert them into database. and found out that if month or day is single digit, for example, june, it will just insert 6 into the database.
    But i actually need 06 instead of 6.
    can anyone help me?
    how to add a 0 infront?

    you can use SimpleDateFormat:
    http://java.sun.com/j2se/1.4.1/docs/api/java/text/SimpleDateFormat.html
    i provide you code example of how to test it: but there i use deprecated method (as i didn't want to use DateFormat for geting new Date object)
    so, i beg you, don't you use that deprecated constructor.
    import java.text.*;
    class SimpleDFTest {
    public static void  main(String[] args) {
      SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
      for (int i = 0; i < 13; i++) {
       System.out.println("Some date: " + sdf.format(
         /* java.util.Date(int,int,int) is deprecated, DON'T use it */
         new java.util.Date(/*1900 + */ 103, i, 5 + i)
    }to compile it i used javac -deprecation SimpleDFTest.java
    note that i print out 13 rows, (month varys from 0 to 12, and day from 5 to 17), that's because i wasn't suer if month should be given as int from 0 to 11 or from 1 to 12.
    you may figure out which it is and thenn add 1 to currentMonth, or not.
    anyhow, it prints days and months out just the way you need it, with dwo digits.

  • How to add rows using DefaultTableModel?

    I'm trying to figure out the ins-and-outs of creating a dynamic table.
    I looked for a tutorial, but none of the example programs I found dealt with my particular issue, nor did they explain anything.
    For instance, most of the examples looked like this:
            table = new JTable();
            defaultModel = new DefaultTableModel(10,5);
            setModel(defaultModel);But that doesn't work for me -- I'm creating a class that EXTENDS DefaultTableModel, and so if I want to send in parameters, I have a problem.
              public MyTableModel() {
                            super(data, columnNames);
                    ...The above code complains that "you can't access data or columnNames until you call super()!"
    But I've seen plenty of example code that DOES send in parameters to super(). How do they get away with that? Is it because they are parameters to the constructor, whereas private/public members of the class are somehow different?
    I thought a variable is a variable -- why is one allowed but not the other?
    Lastly, I'm trying to figure out, practically speaking, how to load a database with X items, and be able to add rows later. Does that mean I need to use a vector for my data instead of Object[][]?
    I've seen BOTH AbstractDataModel and DefaultTableModel used with dynamic tables -- is there any difference between them as far as dynamic tables are concerned?
    I was under the impression that I needed to "switch" from ADM to DTM if I wanted to be able to add rows to my table at runtime.
    Here are some references to previous discussions I found/participated in on this topic:
    http://forum.java.sun.com/thread.jspa?threadID=5224966
    http://forum.java.sun.com/thread.jspa?threadID=439141&start=0&tstart=0
    Thanks in advance for any help,
    Matthew

    -> I'm creating a class that EXTENDS DefaultTableModel, and so if I want to send in parameters, I have a problem
    Well, you would pass in the data and columnNames as parameter when you create your table model.
    -> Lastly, I'm trying to figure out, practically speaking, how to load a
    -> database with X items, and be able to add rows later. Does that
    -> mean I need to use a vector for my data instead of Object[][]?
    You just said you extended DefaultTableModel. Well you don't need to do anything it already manages the data for you. You just use the methods provided to update and change the data.
    -> I've seen BOTH AbstractDataModel and DefaultTableModel used with dynamic tables
    No you haven't. You really don't understand what an AbstractDataModel is do you? Its nothing. You can't use it. It doesn't have any storage for the data, and since there is no data storage you can't access the data or change it. You can't even create an AbstractTableModel. Read your Java text on what an Abstract class it.
    The DefaultTableModel extends the AbstractTableModel to provide data storage and ways to get the data and change the data. It notifies the table when any change is made to the data so the table can repaint itself.
    -> How to add rows using DefaultTableModel?
    Finally, the DTM provides methods that make the model dynamic. Methods for adding and removing rows or adding and removing columns. Read the API for more information.
    If you still don't understand how how the methods work then search the forum for examples that use the methods you don't understand. I've posted an example the uses the methods required to add rows or columns.

  • How to add fields to already loaded cube or dso and how to fill records in

    how to add fields to already loaded cube or dso and how to fill  it.can any one tell me the critical issues in data loading process..?

    This is sensitive task with regards to large volumes of data in infoproviders.
    The issue is to reload of data in case of adjusted structures of infoproviders.
    Indeed there are some tricks. See following:
    http://weblogs.sdn.sap.com/cs/blank/view/wlg/19300
    https://service.sap.com/sap/support/notes/1287382

  • How to add a library (libSomeRandomlib.so) to a project....??

    Ok, so I've been trying to get CERN's ROOT program/libraries to work in an xcode project for a while, but I'm running into one really weird error, and I think I may just not know how to add a library to a project correctly.
    Suppose I create a new Xcode C++ command line tool project. I hit Build and go, and it gives me a nice little Hello World! in the console, just as it should. If I then click on the project in Groups & Files, go to Project>Add to Project..., and choose, say, libCint.so, from my root/lib directory, and click ok, then click Build & Go, I get an error in the console:
    dyld: Library not loaded: @rpath/libCint.so
    Referenced from: /Users/paulthompson/Documents/Programming/Build Products/Debug/LibraryIncludeTest
    Reason: image not found
    sharedlibrary apply-load-rules all
    Data Formatters temporarily unavailable, will re-try after a 'continue'. (Cannot call into the loader at present, it is locked.)
    My assumption is that either I'm missing a step in the process of adding a library, or else there is something jacked up with the libraries themselves. Anyone have any advice?
    Thanks,
    Paul
    EDIT* Oh, I should mention that the actuall binary that gets built after adding the library WILL execute properly in the Finder, or from terminal, just not with the Build & Go, or Go commands from within xcode.
    Message was edited by: TraxusIV

    TraxusIV wrote:
    Results of otool:
    LibraryIncludeTest:
    @rpath/libCint.so (compatibility version 0.0.0, current version 0.0.0)
    /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 123.0.0)
    Macintosh-9:Debug paulthompson$ otool -L /Applications/CERNRoot/root/lib/libCint.so
    /Applications/CERNRoot/root/lib/libCint.so:
    @rpath/libCint.so (compatibility version 0.0.0, current version 0.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.0)
    /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)
    I honestly don't know much about @rpath. I found this page that explains it a bit more: http://blogs.sun.com/dipol/entry/dynamiclibraries_rpath_andmac
    So, since I don't want to deploy with the environment variable set, I should ask, what IS the correct, MacOS X way to do it?
    The best way to find that is to look at how Apple does it. They put frameworks in /System/Library/Frameworks and regular shared libraries in the standard places. You can do the same. Put your frameworks into /Library/Frameworks and your shared libraries into /usr/local-based paths.
    If you want to create stand-alone executables that can be installed via drag-n-drop, you can put shared libraries inside the application bundle. If your shared libraries/frameworks are elsewhere, you will need some sort of installer to get them installed.
    I've been sifting through Apple's developer documentation but I have yet to find a concise, straightforward explanation of how to add shared libraries. I'm horribly confused at this point. Is there a good tutorial available anywhere for both the general unix case of linking to dylibs and .so's, and the Mac specific case?
    Hopefully someone else knows an answer for this one.
    *EDIT* I do already have the variable defined both in ~/.MacOS/environment.plist and also in Xcode as an additional user variable.
    I'm not sure about the whole RPATH thing. Setting environment.plist will define environment variables for use in the Finder, but that is really a hack. There are better ways to do it, but if you are porting some open-source programs, that may be the only way. You should be able to define those variables in Xcode. You have to selected the debug executable under "Exectuables"

  • How to add A single row at the middle of the table in a Webi report

    Hi,
         I created a Webi report using Universe(Created universe using bex query).Now i have a requirement to display a row at the middle of a report. Can you please tell me ,how to add a sigle row at the middle of a Webi report.
                                                    Thanks in advance
    Regards
    Monika

    Hi Monika,
    It is not really possible to add a row (I assume you mean of unrelated data) to the middle of a table in a report. You can add a new table with a single row between two tables. For instance you could add a new one row table, or even single cells which are positioned relatively between two tables. Possibly a block on top of another. But this gets tricky.
    Can you explain in more detail what you are trying to do?
    Thanks

  • How to create a job card and how to add waranty card in sales order

    I have one scenario for CS.the scenario is realted to automotive industry. Basically its a trading industry of HCV,MCV,LCV apart from that they will do servicing also. First the customer comes for a service.he is having free services. he will have waranty for spare parts of the vehicle. once he comes for servicing first the executive will take complains from the customer after that a Job card will be issued to the customer. there his chasis no ,engine no and registration no will be there. once enter the chasis no entire customer details has to come. how many free services he is having for how many kilo meters.then job card will go to the spare parts dept.that dept will issue the spare parts.then they will invoice the customer. he will pay the payment.and finally the gate pass will be given to the customer to deliver the vehicle.
    painful area is how to create a job card and how to add waranty in sales order.
    Regards,
    Venkat

    Hi,
    Have u resolved it then Please let me know !!! It is a very interesting problem and owuld like to know the solution...
    Regards
    Krishna

  • How to add apache to an exisitng BOXI31 presently running on IIS

    Hi Tim,
    I know its rude that I directly mailed you but i am not able to post on the SAP forum due to some reasons I don't know. So please if you can help me I would be highly indebted.
    I have a multiple server installation.
    Number of Servers : 4
    Number of CMS : 2
    Application tier on 2 servers.
    Web tier on 2 servers.
    The problem is when i login my .NET infoview works fine but my Java infoview doesn't.
    I found the error that the CCM doesn't have Tomcat Apache Server.
    So my guess is thats the reason why the java infoview is not working.
    Please help how to add the Apache to the CCM.
    Regards
    Sid

    Hi,
    You need to run custom installation to install Java Web components on your server box and choose to install
    tomcat app server
    - Subhodeep

  • How to add description of a column of a table in SQL Azure

    Hi
    I have some tables in my application database where there are descriptions added against certain columns. Needless to say they were done by using sp_addextendedproperty.
    Now I am trying to migrate the Database to SQL Azure. SQL Azure does not support sp_addextendedproperty.
    Hence I am not able to figure out how to add descriptions to those columns.
    Any help would be much appreciated.
    Thanks
    Soumyadeb

    Hello,
    Just as Latheesh post above, Windows Azure SQL database are not support extended stored procedures. That’s one of the limitations on SQL database, and I don’t know there is another way to achieve the same on Azure.
    Regards,
    Fanny Liu
    Fanny Liu
    TechNet Community Support

  • How to add more fields at level task for importing to MsProject

    Hi everyone,
    We would like to have the same number of fields either for importing as exporting; or at least, the fields that we need.
    The problem is when we are configurating the fields for exporting from cProjects to MsProject, we found 81 available fields and then we don't find the same amount for importing (34). So, in some cases we don't find fields which were configurated for exporting and it is no posible to upload the information back because the field is no available for importing.
    Does anyone knows how to add more fields for importing at the cProjects side?
    Thanks a lot,
    CAMILO URIBE

    Some fields can not be migrated because of MsProject designe. The above is the reason why cProjects' customizing does not offer the
    mapping of the same nuember of fields.

  • How to ADD field in iview ?

    hi,
    in portal-iview i want to add a field.
    when i go to 'portal-content -> open the iview with right click -> preview' and then
    do ctrl-alt-right-mouse click i got to the customizing of the fields.
    i know how to HIDE fields there, but i don't know how to add fields ? in the list
    of the fields the necessary fields are available, BUT i only have to options:
    hide -> YES or NOT PERSONALIZED
    any ideas ?
    reg, Martin

    Gopal,
    the root element of this fields does NOT have the option 'decorate'.
    it is the quoata overview of ESS : sap.com/ess~quotas
    the top of the tree has option 'decorate', but this is above the necessary table where
    i select the data.
    my adrl is 
    martin.svik(at)denzel.at
    maybe we can 'change' some screenshots where you can send me yours and i can
    send you mine to explain it in a better way
    reg, Martin

  • How to add more drop zones or movies in an idvd menu

    I was building a dvd in idvd and ran out of drop zones to fill but I couldn't figure out how to add more drop zones.
    I tried different templates but I could find none that had more than 12 drop zones.
    Then I was adding movies to the main menu and idvd refused to allow more movies added when I reached 10 movies. It said that the template did not accept more movies.
    I tried a few other templates and could not get it to accept more.
    I don't want to add submenus because the movies being used do not lend themselves to being put into different submenus.
    Is there some way to add more than the default drop zones in an idvd template and to add more movies in a menu without having to use submenus?
    Thanks for any advice.

    I couldn't figure out how to add more drop zones
    Sorry, the templates 'are what they are'.
    I don't want to add submenus because the movies being used do not lend themselves to being put into different submenus.
    You need to figure out how to work with what is available.
    If you want more freedom, buy Apple's Final Cut Studio and learn to use DVD Studio Pro.

  • How to add a gradient or 50% transparent fill to an .ai imported path?

    Hello All;
    I need some help. My task sounds simple enough but not sure how to accomplish it.
    I created the following path in Illustrator (See attached illustration - the top one). This is actually for a lower-third graphic.
    I have been successful at importating that into .ai. Though should I be using a solid or a shape layer or doesn't it matter ?
    I can add a stroke which affects the color and thickness of the outlines OK.
    However, I can't figure out how to add either a gradient fill or one that is 50% transparent ? Can anyone help ?
    Oh ... I'll mention I'm using After Effects CS3.
    Thanks.
    Tim

    Rick;
    I've used Illustrator for quite a while both at home and at work but I really havn't had to do anything that complex yet. Same goes for Photoshop. I bought DVD tutorials for most of the productivity software I use and when you gave your first explanation, I watched the DVD tutorial on Importing into AE so I know what you're referring to when you say to import as composition. So far, I've only tried to import into AE by copying and pasting. I think that's why I just got the path and not the background. I'll try importing a composition shortly and see if I get the fill too. I actually found a tutorial on making the type of shape I need to in Photoshop so maybe I'll try that instead of Illustrator and then import that into AE.
    Btw - It may not actually be a gradient fill I need to use but instead a solid fill with the top half lighter and buttom half darker.
    In case you're interested, here's actually what I'm trying to create for a video project. I could actually buy the animation for $8 but I figured that this can't be that difficult and I need to learn this stuff anyway ... http://videohive.net/item/lower-third-15-different-colour-schemes/145337?WT.ac=category_th umb&WT.seg_1=category_thumb&WT.z_author=berol
    Tim

Maybe you are looking for

  • MBP 15,4" Early 2008 - VISTA 64-bit:Wi-Fi issue, BSOD issue, uTorrent issue

    If you noticed following problems under Vista (64-bit and 32-bit) and/or Windows XP SP2/SP3: - MBP looses Wi-Fi connection and can not login again to Wi-Fi router (restart needed to solve this) - random crashes/BSODs/restarts, - problems with uTorren

  • Firefox Menu and some other forms show blank

    When I open the Firefox side menu (the new one with the three horizontal lines) initially it shows fine, but then if I try to click anything in it or open it again, it only opens blank space and I cannot see anything. Same goes for any pop-up forms (

  • Using UNICODE fonts in Adobe Ps CS5

    Hi friends and professionals: I've got problem with Ps CS5 when I use UNICODE fonts (this is not the case for former Ps CS versions). Someone who know how to fix this problem, please help! Thanks. TLe PS: Ps CS5 lastest version/ Windows 7 64bit /Dell

  • SMS - Character Count

    The option is enabled ... But it's not working, It's not supposed to show the number of characters below the send button ?

  • More FB 4.5 BlazeDS bugs

    For FB 4.5 Plugin Mac Cocoa 32 bit: 1. I am having trouble deleting and adding BlazeDS services from the Flash Builder perspective. 2. Re-adding a service now forces me to create an additional valueObject instead of re-using the     one I already cre