Programming project: does this code look clean enough to turn in?

Hi, i was just wanting to know people's opinion on the format of my classes below, i haven't done much java programming and I just want to make sure that this program is easily understood. I will not be able to respond, because I have to wake up in 3 hours for school. So thanks in advance, I will be reading this tomorrow, to see your suggestions, thank you.
here is the scholar class, it is the class that i made to create a scholar(student object) that will be applying for a scholarship and the grades are entered in the ScholarTester class.
I could've done things differently and easier but the professor strictly called for it to be exactly as he stated. I came up with a better, less tedious way, but i couldn't use it. My way was to create a method to randomly generate grades and values to determine the major, but my prof. saw it and made me implement everything in ScholarTester. Also neither of the students will receive the scholarship, that will be determined in project 2 my professor said.
package project1;
import java.util.*;
* @author Kevin
public class Scholar implements Comparable {
    // private variables
    private String fullName;
    private double gradePointAverage;
    private int essayScore;
    private int creditHours;
    private boolean scienceMajor;
    private double totalScore;
       // constructor for a Scholar object
        public Scholar(String myFullName, double myGradePointAverage, int myEssayScore,
                       int myCreditHours, boolean isScienceMajor){
                this.fullName = myFullName;
                this.gradePointAverage = myGradePointAverage;
                this.essayScore = myEssayScore;
                this.creditHours = myCreditHours;
                this.scienceMajor = isScienceMajor;
        // returns a Scholar object's fullname
        public String getFullName(){
            return fullName;
        // returns a Scholar object's gpa
        public double getGradePointAverage(){
            return gradePointAverage;
        // returns a Scholar object's essay score
        public int getEssayScore(){
            return essayScore;
        /// returns a Scholar object's credit hours
        public int getCreditHours(){
            return creditHours;
        // retruns if a Scholar object is a science major or not
        public boolean getScienceMajor(){
            return scienceMajor;
        // sets a Scholar object's full name
        public String setFullName(String lastName, String firstName){
           fullName = lastName + ", " + firstName;
           return fullName;
        // sets a Scholar object's gpa
        public double setGradePointAverage(double a){
            gradePointAverage = a;
            return gradePointAverage;
        // sets a Scholar object's gpa
        public int setEssayScore(int a){
            essayScore = a;
            return essayScore;
        // sets a Scholar object's credit hours
        public int setCreditHours(int a){
            creditHours = a;
            return creditHours;
        // sets a Scholar's major to a science major or not a science major
        public boolean setScienceMajor(boolean a){
            scienceMajor = a;
            return scienceMajor;
        // calculates a Scholar object's score
        public double getScore(){
            totalScore = (gradePointAverage*5) + essayScore;
            if (scienceMajor == true)
                totalScore += .5;
            if (creditHours >= 60 && creditHours <90)
                totalScore += .5;
            else if (creditHours >= 90)
                totalScore += .75;
            return totalScore;
        // compares two scholar objects.
        public int compareTo(Object obj){
            Scholar otherObj = (Scholar)obj;
            double result = getScore() - otherObj.getScore();
            if (result > 0)
                return 1;
            else if (result < 0)
                return -1;
            return 0;
        // returns the highest scoring of two Scholar objects
        public static Scholar max(Scholar s1, Scholar s2){
            if (s1.getScore() > s2.getScore())
                System.out.println(s1.getFullName() + " scored higher than " +
                                   s2.getFullName() + ".\n");
            else
               System.out.println(s2.getFullName() + " scored higher than " +
                                   s1.getFullName() + ".\n");
            return null;
        // returns the highest of 3 student objects
        public static Scholar max(Scholar s1, Scholar s2, Scholar s3){
            if (s1.getScore() > s2.getScore() && s1.getScore() > s3.getScore())
                System.out.println(s1.getFullName() + " scored the highest" +
                        " out of all three students.");
            else if (s2.getScore() > s1.getScore() && s2.getScore() > s3.getScore())
                System.out.println(s2.getFullName() + " scored the highest" +
                        " out of all three students.");
            else if (s3.getScore() > s2.getScore() && s3.getScore() > s1.getScore())
                System.out.println(s3.getFullName() + " scored the highest" +
                        " out of the three students.");
            return null;
        // toString method for a Scholar object
        public String toString(){
            return  "Student name: " + fullName + " -" + " Grade Point Average: "
                    + gradePointAverage  + ". " + "Essay Score: " + essayScore + "."
                    + " Credit Hours: " + creditHours + ". "  +  " Science major: "
                    + scienceMajor + ".";
}here's the ScholarTester class:
package project1;
import java.util.*;
* This program creates Scholar objects that are applying for a scholarship
* @author Kevin
public class ScholarTester {
public static void main(String [] args){
System.out.println("This program was written by Kevin Brown. \n");
System.out.println("--------Part 1--------\n");
// attributes for a scholar object named abraham
double abrahamGpa;
int abrahamEssayScore;
int abrahamCreditHours;
int scienceMajorValueAbraham;
boolean abrahamIsScienceMajor;
    // random numbers used for each scholar object.
    Random doubleGpa = new Random();
    Random intGpa = new Random();
    Random essayScore = new Random();
    Random creditHours = new Random();
    Random scienceMajor = new Random();
        // randomly creates abraham's statistics
        abrahamGpa = doubleGpa.nextDouble() + intGpa.nextInt(4);
        abrahamEssayScore = essayScore.nextInt(6);
        abrahamCreditHours = creditHours.nextInt(121);
        scienceMajorValueAbraham = scienceMajor.nextInt(2);
            if (scienceMajorValueAbraham == 0)
             abrahamIsScienceMajor = true;
            else
             abrahamIsScienceMajor = false;
Scholar abraham = new Scholar("Lincoln, Abraham", abrahamGpa,
                                  abrahamEssayScore, abrahamCreditHours,
                                  abrahamIsScienceMajor);
System.out.println(abraham);
double georgeGpa;
int georgeEssayScore;
int georgeCreditHours;
int scienceMajorValueGeorge;
boolean georgeIsScienceMajor;
    // randomly creates george's statistics
    georgeGpa = doubleGpa.nextDouble() + intGpa.nextInt(4);
    georgeEssayScore = essayScore.nextInt(6);
    georgeCreditHours = creditHours.nextInt(131);
    scienceMajorValueGeorge = scienceMajor.nextInt(2);
         if (scienceMajorValueGeorge == 0)
             georgeIsScienceMajor = true;
         else
             georgeIsScienceMajor = false;
// new scholar object is created from the existing attributes
Scholar george = new Scholar("Bush, George",  georgeGpa, georgeEssayScore,
                                      georgeCreditHours, georgeIsScienceMajor);
System.out.println(george + "\n");
System.out.println("--------Part 2--------\n");
System.out.println(abraham.getFullName() + " scored " + abraham.getScore() + ".");
System.out.println(george.getFullName() + " scored " + george.getScore() + ".\n");
System.out.println("--------Part 3--------\n");
/* comparing george bush and abraham lincoln's scores and printing them out to
         show that the compareTo method is working*/
         System.out.println(abraham.getFullName() + " scored "
                            + abraham.getScore() + ".");
         System.out.println(george.getFullName() + " scored "
                            + george.getScore() + ".\n");
if(abraham.compareTo(george) == 1)
    System.out.println(abraham.getFullName() + " scored higher than " +
            george.getFullName() + ".\n");
else
    System.out.println(george.getFullName() + " scored higher than " +
            abraham.getFullName() + ".\n");
System.out.println("--------Part 4--------\n");
    // prints out scores to show proof that the Scholar.max method is working right.
    System.out.println(abraham.getFullName() + " scored "
                       + abraham.getScore() + ".");
    System.out.println(george.getFullName() + " scored "
                       + george.getScore() + ".\n");
    Scholar.max(abraham, george); // maximum score between abraham and george.
// variables for a scholar object named thomas.
    double thomasGpa;
    int thomasEssayScore;
    int thomasCreditHours;
    int scienceMajorValueThomas;
    boolean thomasIsScienceMajor;
    // randomly creates thomas' statistics
        thomasGpa = doubleGpa.nextDouble() + intGpa.nextInt(4);
        thomasEssayScore = essayScore.nextInt(6);
        thomasCreditHours = creditHours.nextInt(131);
        scienceMajorValueThomas = scienceMajor.nextInt(2);
             if (scienceMajorValueThomas == 0)
                 thomasIsScienceMajor = true;
             else
             thomasIsScienceMajor = false;
         // new scholar object created from existing attributes
         Scholar thomas = new Scholar("Jefferson, Thomas", thomasGpa, thomasEssayScore,
                                      thomasCreditHours, thomasIsScienceMajor);
         System.out.println("New student added - " + thomas + "\n");
         // returns all 3 students scores to show proof that the Scholar.max method is working right
         System.out.println(thomas.getFullName() + " scored " + thomas.getScore());
         System.out.println(abraham.getFullName() + " scored " + abraham.getScore());
         System.out.println(george.getFullName() + " scored " + george.getScore() + "\n");
         // highest score of all three scholars
         Scholar.max(abraham, george, thomas);
}Thanks for reading this long and boring project.

On comments: don't include a comment that just repeats syntax:
// constructor for a Scholar object
public Scholar(String myFullName, ...Anyone knowing Java syntax doesn't need that comment and gains nothing
from its presence, and anyone not knowing Java syntax shouldn't be reading
a listing.
On parameter names: a isn't very imaginative or prescriptive. (See next code.)
On setters returning the argument:
public int setCreditHours(int creditHours ){
    this.creditHours = creditHours ;
    return creditHours;
}1. Most people keep it simple and use a void return type.
2, The next most common convention is to return this:
public Scholar setCreditHours(int creditHours){
    this.creditHours = creditHours ;
    return this;
}Then you can chain calls, which is occasionally useful:
scholar.setCreditHours(4).setEssayScore(2);3. If you insist on returning the argument, note that this is a one-liner:
public in setCreditHours(int creditHours){
    return this.creditHours = creditHours ;
}

Similar Messages

  • Does this code look right

    <?php
    $name=$_POST['name'];
    $email=$_POST['email'];
    $location=$_POST['location'];
    mysql_connect("your.hostaddress.com", "username", "password") or die(mysql_error());
    mysql_select_db("Database_Name") or die(mysql_error());
    mysql_query("INSERT INTO `data` VALUES ('$name', '$email', '$location')");
    Print "Your information has been successfully added to the database.";
    ?>

    What colors? You mean in code view?
    Actually your last line should be this -
    print ("Your information has been successfully added to the database.");
    Other than that, the code and its coloring are correct as far as I can tell.

  • Why does this code not work?

    String answer = new String("");
    in = new BufferedReader(new InputStreamReader( connection.getInputStream ()));
    String test = new String("");
    for (int i = 0 ; i < 1000 ; i++)
    answer = in.readLine();
    if (answer == null)
    System.out.println ("null");
    break;
    else
    test += answer;
    System.out.println ("answer: " + answer);
    System.out.println ("test: " + test);
    Many times, the loop will go through 2 iterations but each time, test is only equal to the first answer. The second, third, fourth etc.time it goes through the loop, it should concatenate the value of answer to the end of the string variable test. So why is it that whenever i run the program that has this code, the loop might lloop many times (let's say 2 time) but the value of test is only the first answer, and not the first answer concatenated with the second answer.

    It worked for me...my code looks like this...i used FileInputStream instead of connection..
    import java.io.*;
    class Forum {
      public static void main(String a[]) throws IOException{
        String answer = new String("");
        BufferedReader in = new BufferedReader(new InputStreamReader( new FileInputStream("hi.txt")));
        String test = new String("");
        for (int i = 0 ; i < 1000 ; i++)
        answer = in.readLine();
        if (answer == null)
        System.out.println ("null");
        break;
        else
        test += answer;
        System.out.println ("answer: " + answer);
        System.out.println ("test: " + test);
    my hi.txt is like this:
    fasd rea reks krie
    fsdfasd
    asdfasd
    sfasdf
    asdfasd
    The output is
    answer: fasd rea reks krie
    answer: fsdfasd
    answer: asdfasd
    answer: sfasdf
    answer: asdfasd
    null
    test: fasd rea reks kriefsdfasdasdfasdsfasdfasdfasd
    Is this not the way u want???

  • Action_URL_NEW_uncheck continue playing the project: does this mean the projects halts until you come back to it?

    Captivate
    Action_URL_NEW_uncheck continue playing the project: Does this mean the project will halt until the viewer comes back to it?

    Hi,
    When you punchout to this web shop, have you handled the OCI suspend mode in SRM? Otherwise, when returning and generating the resume mode for OCI, it will not know what session to resume, I suggest configuring a catalog normally in the SRM_SERVER using the MDM or CCM catalogs and then reviewing the http flow of the call and return to see how the program flows.
    Regards,
    Jason

  • I have just tried to sync my iphone. Error message saying it cannot be synced has popped up quoting error code (-50). I have just removed old iphone backups from itunes but was very careful to not delete the current one. What does this code mean?

    Hi there,
    I have just tried to sync my iphone.
    Worryingly an error message saying it cannot be synced has popped up quoting error code (-50)
    I have just removed old iphone backups from itunes but was very careful to not delete the current one
    What does this code mean?

    http://support.apple.com/kb/TS1583

  • What does " this code must be redeemed in the Australian storefront " mean? And how can I fix it?

    What does " this code must be redeemed in the Australian storefront " mean? And can I fix it?

    All iTunes gifts and gift cards are country-specific, they can only be redeemed and used in their country of issue. Are you in Australia with an Australian billing address on your account ? If you are then try going to the bottom of the Featured tab in the App Store app on your iPad and tap on your account id, tap on 'View Apple ID' on the popup and log into your account, and then select the Country/Region section and select Australia.
    If you are not in Australia then you won't be able to use it.

  • When ever i turn cellular data off then back on my mobile internet doesent work why does this happen?, when ever i turn cellular data off then back on my mobile internet doesent work why does this happen?

    when ever i turn cellular data off then back on my mobile internet doesent work why does this happen?, when ever i turn cellular data off then back on my mobile internet doesent work why does this happen?

    You only asked the question 4 times.  You have to repeat it at least 10 times to get an answer here, and then only if you supply useful info about your phone.

  • Simple Question: Why does this code not exit properly?

    This code is pretty simple. All I want to do is load and play a sound file in an application, but this code to load the sound file does not exit properly. I know that some resources must be allocated which I need to deallocate in order to shut down the process, but I don't know what to call to do a proper shut-down. Any help would be appreciated.
    -adam
    import java.applet.Applet;
    import java.applet.AudioClip;
    import java.net.MalformedURLException;
    import java.net.URL;
    public class PlaySoundTest extends java.applet.Applet
    public static void main( java.lang.String[ ] aryArgs )
    java.net.URL urlSound = null;
    try
    urlSound = new java.net.URL( "file:/" + aryArgs[ 0 ] );
    catch( java.net.MalformedURLException murle )
    murle.printStackTrace( );
    System.exit( 1 );
    java.applet.AudioClip acSound = java.applet.Applet.newAudioClip( urlSound );

    HI , If u'r still looking for the solution, this code is working on my system -
    import java.applet.Applet;
    import java.applet.AudioClip;
    import java.net.MalformedURLException;
    import java.net.URL;
    public class PlaySoundTest extends java.applet.Applet
    public static void main( java.lang.String[ ] aryArgs ){
    java.net.URL urlSound = null;
    try{  //rahul
    try
    urlSound = new java.net.URL( "file:" + aryArgs[ 0 ] );
    catch( java.net.MalformedURLException murle )
    murle.printStackTrace( );
    System.exit( 1 );
    urlSound = new java.net.URL( "file:" + aryArgs[ 0 ] );
    java.applet.AudioClip acSound = java.applet.Applet.newAudioClip( urlSound );
    if(acSound != null){
    acSound.play();
    catch( Exception murle )
    {        //rahul
    murle.printStackTrace( );
    System.exit( 1 );
    }//main
    The only change I made was in the URL part - file: instead of file:/ .
    The other was of course to play the soundclip ...... :- ) I got really confused the first time I played it .

  • Does this code effect performance.

    I am doing some code now :) and I did a method like this, however I do not know if it effects performance for the whole application when the method is being called, or weather it is a good coding standard.
    The code in question is the following:
    public void myMethid(){
       class c{
          public c(String s){
              System.out.println(s);
       c myC = new c("Hello");
    }I know this is a stupid example, however would such a think effect performance, or be wrong? ... would it be better to just declare c as an external class?
    regards,
    sim085

    I have seen ppl complaining about cross posts, but what I am going to do here is cross post my answer, which I feel might be helpful in this situation, and considering that it still lies in the grey area:-
    "I smell a very interesting discussion stemming out of it, but your question is as open ended as it could be, what kind of web application and what performance. performance is the most misused word I have come across in a lot of design considerations. It is not one parameter you could measure but a combination of different considerations, which would be as follows:-
    1) Response time
    2) Responsivesness
    3) Latency
    4) Thoroughput
    5) Load
    6) Load sensitivity
    7) Efficiency
    8) capacity
    9) scalabilty
    You might want to look on the web as to what they mean since I am not going to go into that detail. But these attributes are independent of each other, an application with good latency might be poor in scalability or other way around, so it depends as to whats the nature and requirements of the app you are looking at then deciding which way you would want to go. Its not that simple.
    Secondly I would quote Martin Fowler from his book "Patterns of Enterprise Application Architecture":-
    "Too often I have seen designs used or rejected because of performance considerations, which turn out to be bogus once somebody actually does some measurements on the real setup used for the application."
    So please go back to the requirements and try to figure out what you are actually looking for."

  • Why does this code fail in command line?

    I am using the "ListDemo" from the java swing tutorial. If I compile it on the command line
    javac ListDemo.java
    It compiles fine. Then when I run it, it says:
    C:\Development\Java\Projects\Projects>java ListDemo
    Exception occurred during event dispatching:
    java.lang.NoSuchMethodError
    at ListDemo.createAndShowGUI(ListDemo.java:196)
    at ListDemo.access$400(ListDemo.java:7)
    at ListDemo$1.run(ListDemo.java:217)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    Yet when I load up the same file into Netbeans, it compiles and runs fine! Here is the file:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    /* ListDemo.java is a 1.4 application that requires no other files. */
    public class ListDemo extends JPanel
                          implements ListSelectionListener {
        private JList list;
        private DefaultListModel listModel;
        private static final String hireString = "Hire";
        private static final String fireString = "Fire";
        private JButton fireButton;
        private JTextField employeeName;
        public ListDemo() {
            super(new BorderLayout());
            listModel = new DefaultListModel();
            listModel.addElement("Alan Sommerer");
            listModel.addElement("Alison Huml");
            listModel.addElement("Kathy Walrath");
            listModel.addElement("Lisa Friendly");
            listModel.addElement("Mary Campione");
            listModel.addElement("Sharon Zakhour");
            //Create the list and put it in a scroll pane.
            list = new JList(listModel);
            list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            list.setSelectedIndex(0);
            list.addListSelectionListener(this);
            list.setVisibleRowCount(5);
            JScrollPane listScrollPane = new JScrollPane(list);
            JButton hireButton = new JButton(hireString);
            HireListener hireListener = new HireListener(hireButton);
            hireButton.setActionCommand(hireString);
            hireButton.addActionListener(hireListener);
            hireButton.setEnabled(false);
            fireButton = new JButton(fireString);
            fireButton.setActionCommand(fireString);
            fireButton.addActionListener(new FireListener());
            employeeName = new JTextField(10);
            employeeName.addActionListener(hireListener);
            employeeName.getDocument().addDocumentListener(hireListener);
            String name = listModel.getElementAt(
                                  list.getSelectedIndex()).toString();
            //Create a panel that uses BoxLayout.
            JPanel buttonPane = new JPanel();
            buttonPane.setLayout(new BoxLayout(buttonPane,
                                               BoxLayout.LINE_AXIS));
            buttonPane.add(fireButton);
            buttonPane.add(Box.createHorizontalStrut(5));
            buttonPane.add(new JSeparator(SwingConstants.VERTICAL));
            buttonPane.add(Box.createHorizontalStrut(5));
            buttonPane.add(employeeName);
            buttonPane.add(hireButton);
            buttonPane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
            add(listScrollPane, BorderLayout.CENTER);
            add(buttonPane, BorderLayout.PAGE_END);
        class FireListener implements ActionListener {
            public void actionPerformed(ActionEvent e) {
                //This method can be called only if
                //there's a valid selection
                //so go ahead and remove whatever's selected.
                int index = list.getSelectedIndex();
                listModel.remove(index);
                int size = listModel.getSize();
                if (size == 0) { //Nobody's left, disable firing.
                    fireButton.setEnabled(false);
                } else { //Select an index.
                    if (index == listModel.getSize()) {
                        //removed item in last position
                        index--;
                    list.setSelectedIndex(index);
                    list.ensureIndexIsVisible(index);
        //This listener is shared by the text field and the hire button.
        class HireListener implements ActionListener, DocumentListener {
            private boolean alreadyEnabled = false;
            private JButton button;
            public HireListener(JButton button) {
                this.button = button;
            //Required by ActionListener.
            public void actionPerformed(ActionEvent e) {
                String name = employeeName.getText();
                //User didn't type in a unique name...
                if (name.equals("") || alreadyInList(name)) {
                    Toolkit.getDefaultToolkit().beep();
                    employeeName.requestFocusInWindow();
                    employeeName.selectAll();
                    return;
                int index = list.getSelectedIndex(); //get selected index
                if (index == -1) { //no selection, so insert at beginning
                    index = 0;
                } else {           //add after the selected item
                    index++;
                listModel.insertElementAt(employeeName.getText(), index);
                //If we just wanted to add to the end, we'd do this:
                //listModel.addElement(employeeName.getText());
                //Reset the text field.
                employeeName.requestFocusInWindow();
                employeeName.setText("");
                //Select the new item and make it visible.
                list.setSelectedIndex(index);
                list.ensureIndexIsVisible(index);
            //This method tests for string equality. You could certainly
            //get more sophisticated about the algorithm.  For example,
            //you might want to ignore white space and capitalization.
            protected boolean alreadyInList(String name) {
                return listModel.contains(name);
            //Required by DocumentListener.
            public void insertUpdate(DocumentEvent e) {
                enableButton();
            //Required by DocumentListener.
            public void removeUpdate(DocumentEvent e) {
                handleEmptyTextField(e);
            //Required by DocumentListener.
            public void changedUpdate(DocumentEvent e) {
                if (!handleEmptyTextField(e)) {
                    enableButton();
            private void enableButton() {
                if (!alreadyEnabled) {
                    button.setEnabled(true);
            private boolean handleEmptyTextField(DocumentEvent e) {
                if (e.getDocument().getLength() <= 0) {
                    button.setEnabled(false);
                    alreadyEnabled = false;
                    return true;
                return false;
        //This method is required by ListSelectionListener.
        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting() == false) {
                if (list.getSelectedIndex() == -1) {
                //No selection, disable fire button.
                    fireButton.setEnabled(false);
                } else {
                //Selection, enable the fire button.
                    fireButton.setEnabled(true);
         * Create the GUI and show it.  For thread safety,
         * this method should be invoked from the
         * event-dispatching thread.
        private static void createAndShowGUI() {
            //Make sure we have nice window decorations.
            JFrame.setDefaultLookAndFeelDecorated(true);
            //Create and set up the window.
            JFrame frame = new JFrame("ListDemo");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Create and set up the content pane.
            JComponent newContentPane = new ListDemo();
            newContentPane.setOpaque(true); //content panes must be opaque
            frame.setContentPane(newContentPane);
            //Display the window.
            frame.pack();
            frame.setVisible(true);
        public static void main(String[] args) {
            //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();

    You are not running this code under JDK 1.4
    The setDefaultLookAndFeelDecorated method requires JDK 1.4 version.

  • Please explain what does this code does exactly

    Can any one explain me what does the below code does.
    This is the code written in one of the BADI (ME_PO_PRICING_CUST) .This badi will be triggered when a sales order delivery address is changed and while saving it this will be triggered. Over all what i come to know is they re trigerring a new version in this code. Can anyone explain me what exactly they are doing in this.Thanks...
    METHOD IF_EX_ME_PO_PRICING_CUST~PROCESS_KOMK.
      FIELD-SYMBOLS: <EKKO> TYPE ANY,
                     <PROCSTAT> TYPE MEPROCSTATE,
                     <FRGKE> TYPE FRGKE,
                     <YNAST> TYPE TABLE,
                     <WA_YNAST> TYPE NAST.
      IM_EKKO-PROCSTAT = 02.
    *break-point.
      ASSIGN ('(SAPLMEPO)EKKO') TO <EKKO>.
      ASSIGN ('(SAPLMEPO)YNAST[]') TO <YNAST>.
      IF <EKKO> IS ASSIGNED.
        ASSIGN COMPONENT 'PROCSTAT' OF STRUCTURE <EKKO> TO <PROCSTAT>.
        ASSIGN COMPONENT 'FRGKE' OF STRUCTURE <EKKO> TO <FRGKE>.
        IF <FRGKE> = 'R'.
          <PROCSTAT> = '02'.
        ENDIF.
      ENDIF.
      IF <YNAST> IS ASSIGNED.
        IF <FRGKE> = 'R'.
          LOOP AT <YNAST> ASSIGNING <WA_YNAST>.
            <WA_YNAST>-AKTIV = 'X'.
          ENDLOOP.
        ENDIF.
      ENDIF.
    ENDMETHOD.

    r_htkl must be a range table. check the declaration part of it.
    p_htkl is a parameter on selection screen i hope.
    so, there are four fields on a range table.(range table are similar to your select options)
    1. SIGN ( I or E  - Inclusive or Exculsive)
    2. OPTION(options like EQ = euqal, BT = Between, CP = contains pattern etc)
    3. LOW (value)
    4. HIGH (value)
    so..
    IF NOT p_htkl IS INITIAL. " checks if some thing is being passed to the parameter
    r_htkl-sign='I'. " give the sign a value I i.e it make inclusive sign
    r_htkl-option='EQ'. " EQ to option means you value will be checked for a equal to condition
    r_htkl-low=p_htkl. " the low field in now assigned the same value of the parameter p_hktl
    APPEND r_htkl. " the range table is appended.
    endif.
    so this range table can be used in select statements as :
    select * from abcd into gt where xyz in r_hktl. ==> this will check for a EQ condition with value in r_hktl-low in database or
    in if statements like : if abc in r_hktl. ==> this will check the EQ condition of abc with the r_hktl-low.
    Had it been
    r_htkl-sign='E'.
    then the condition is same but with a NOT.. that means NOT EQ or NOT BT etc.
    as exclusive of the option.
    etc.
    hope this is clear.
    AND PLEASE CLOSE THE OTHER THREAD (duplicate)

  • What files does this code need?

    I am trying to use this code from Java Examples In A Nutshell.
    It is a short program that involves reading one and writing to another (I think!) The way I understand things is that there has to be two files for the program to be able to run, from_file & to_file . I have attempted to creat two txt files and saved them as these names in the same folder as the app. The code complies as you would expect, when I try to run it I get Usage: FileCopy <source> <destination> and the app never runs. I suspect I have not created the external files properly. If you can see where I have gone wrong let me know, layman's terms please, Dave.

    When running the compiled "FileCopy.class" with java command you must enter the names of files, i.e.;
    java FileCopy "from_file" "to_file"
    in the command line.
    In this case args[0] is "from_file" and args[1] is "to_file."

  • What does this code do

    hi friends, i came across this code, and i am struck at understanding this code,
    usually loop keyword will be followed by itab, but here there is nothing, same with sort.
        SORT.
      LOOP.
        AT NEW MSEG-WERKS.
    some code
        ENDAT.
        AT NEW MSEG-MATNR.
    some code
          NEW-PAGE.
        ENDAT.
        AT DETAIL.
          WRITE:
          / MSEG-LGORT,
            MSEG-BWART,
            MSEG-MBLNR,
            MSEG-ZEILE.
        ENDAT.
        AT END OF MSEG-MATNR.
          SKIP 1.
          WRITE: 'x y z..'
        ENDAT.
        AT END OF MSEG-WERKS.
          SKIP 1.
         WRITE: 'x y z..'
        ENDAT.
      ENDLOOP.
    an some one please explain me this code, little briefly.
    thank you.

    sorry friends, i forgot to tell that the following piece of code was above this code:
    INSERT
    MSEG-WERKS                             "Plant
    MSEG-MATNR                             "Material
    MSEG-MBLNR                             "Material document
    MSEG-ZEILE                             "Material item
    INTO HEADER.
    INSERT
    LIPS-VBELN                             "Delivery
    LIPS-POSNR                             "Delivery item
    MSEG-LGORT                             "Storage location
    MSEG-BWART                             "Movement type
    MSEG-MENGE                             "Quantity
    MSEG-SHKZG                             "Debit/credit
    MSEG-MEINS                                                  "UoM
    INTO DETAIL.

  • Why does this code always gotoAndStop at the same frame?

    The symbol "alldoor" contains the following six frames in sequential order: "door1","red_door1","door2","red_door2","door3" and "red_door3".
    var doors:Array =["door1", "door2", "door3"];
    var doorSelector:String = doors[newDoors(0, doors.length - 1)]
    function newDoors (min:Number, max:Number):Number
    var  doorColors:Number = Math.round(Math.random() * (min - max) + max);
    return doorColors;
    alldoor.gotoAndStop(doorSelector);
    alldoor.addEventListener(MouseEvent.CLICK,changeColors );
    function changeColors(e:MouseEvent)
        if (e.currentTarget.currentLabel == doorSelector)
            e.currentTarget.gotoAndStop(currentFrame + 1);
         I am attempting to get this code select one of the frames starting with the string "door" at start up. Then, the door should move to the frame
    directly following it on the timeline when clicked. However, as the code is written, the frame always jumps to the second frame in the symbol,regardless of what the current label is. What should I change?

    either:
    1.  those frames aren't loaded when that code executes or
    2.  you don't have those labels on the timeline that contains that code or
    3.  there is other code executing after your goto changing your frame
    use the trace() function to debug and find which is your problem.

  • Repaint() an applet from a swing applet, why does this code not work?

    below are three files that work as planned except for the call to repaint(). This is envoked when a button is hit in one applet and it should repaint another applet. I opened them up in a html file that simply runs both applets. If you could see why the repaint doesn't work I'd love to know. good luck.
    //speech1
    import java.awt.*;
    import java.applet.Applet;
    import java.awt.event.*;
    //java extension packages
    import javax.swing.*;
    public class speechapp1 extends JApplet implements ActionListener{
    // setting up Buttons and Drop down menus
    char a[];
    Choice choicebutton;
    JLabel resultLabel;
    JTextField result;
    JLabel enterLabel;
    JTextField enter;
    JButton pushButton;
    TreeTest PicW;
    // setting up applets G.U.I
    public void init(){
    // Get content pane and set it's layout to FlowLayout
    Container container = getContentPane();
    container.setLayout( new FlowLayout() );
    // initialise buttons and shit
    a = new char[30];
    choicebutton = new Choice();
    enterLabel = new JLabel("Test");
    enter = new JTextField(30);
    resultLabel= new JLabel("speech label");
    result = new JTextField(30);
    result.setEditable(false);
    // Add items to Choice Button
    choicebutton.addItem("abc");
    choicebutton.addItem("def");
    choicebutton.addItem("ghi");
    choicebutton.addItem("jkl");
    pushButton = new JButton("Click to continue");
    // Add new Tree from file TreeTest.java
    PicW = new TreeTest();
    // Add buttons to container.
    container.add(resultLabel);
    container.add(result);
    container.add(enterLabel);
    System.out.println("");
    container.add(choicebutton);
    System.out.println("");
    container.add(pushButton);
    pushButton.addActionListener(this);
    //choicebutton.addActionListener( this );
    // Set the text in result;
    result.setText("Hello");
    //public void paint(Graphics gg){
    // result.setText("Hello");
    public void actionPerformed(ActionEvent event){
    // continue when action performed on pushButton
    String searchKey = event.getActionCommand();
    System.out.println("");
    if (choicebutton.getSelectedItem().equals("abc"))
    PicW.getPicWeight(1);
    if (choicebutton.getSelectedItem().equals("def"))
    PicW.getPicWeight(2);
    if (choicebutton.getSelectedItem().equals("ghi"))
    PicW.getPicWeight(3);
    if (choicebutton.getSelectedItem().equals("jkl"))
    PicW.getPicWeight(4);
    System.out.println("repainting from actionPerformed method()");
    PicW.repaint();
    import java.applet.Applet;
    import java.awt.*;
    import java.util.*;
    public class TreeTest extends Applet{
    Tree BackgroundImageTree;
    Tree PlayerImageTree;
    Image snow,baby;
    int weight;
    public void getPicWeight(int w){
    weight = w;
    System.out.println("the new weight has been set at: "+weight);
    this.repaint();
    public void init()
    // initialising trees for backgound images and player images
    BackgroundImageTree = new Tree();
    PlayerImageTree = new Tree();
    // initialising images and correcting size of images to correctly fit the screen
    snow = getImage(getDocumentBase(),"snow.gif");
    baby = getImage(getDocumentBase(),"baby.gif");
    // inserting images into correct tree structure
    System.out.println("inserting images into tree: ");
    // inserting background images into tree structure
    BackgroundImageTree.insertImage(1,snow);
    // inserting players into tree structure
    PlayerImageTree.insertImage(1,baby);
    public void paint(Graphics g){
    System.out.println("Searching for selected Image");
    if((BackgroundImageTree.inorderTraversal(1)==null)&&(PlayerImageTree.inorderTraversal(1)==null)){
    System.out.println("There is no tree with the selected value in the trees");
    }else{
    g.drawImage(BackgroundImageTree.inorderTraversal(1),1,3,this);
    //g.drawImage(PlayerImageTree.inorderTraversal(1),55,150,this);
    import java.awt.*;
    import java.applet.Applet;
    class TreeNode {
    TreeNode left;
    Image data;
    TreeNode right;
    int value;
    public TreeNode(int weight,Image picture){
    left = right = null;
    value = weight;
    data = picture;
    public void insert(int v, Image newImage){
    if ( v< value){
    if (left ==null)
    left = new TreeNode(v,newImage);
    else
    left.insert(v,newImage);
    else if (v>value){
    if (right ==null)
    right = new TreeNode(v,newImage);
    else
    right.insert(v, newImage);
    public class Tree{
    private TreeNode root;
    public Tree() {
    root = null;
    public void insertImage(int value, Image newImage){
    if (root == null)
    root = new TreeNode(value,newImage);
    else
    root.insert(value,newImage);
    // in order search of tree.
    public Image inorderTraversal(int n)
    return(inorderHelper(root,n));
    private Image inorderHelper(TreeNode node, int n){
    Image temp = null;
    if (node == null)
    return null;
    if (node.value == n ){
    return(node.data);
    temp = inorderHelper(node.left,n);
    if (temp == null){
    temp = inorderHelper(node.right,n);
    return temp;
    }

    I can fix your problems
    1. You get an error here because you can only invoke the superclass's constructor in the subclass's constructor. It looks like that's what you're trying to do, but you're not doing it right. Constructors don't return any value (actually they do, but it's implied, so you don't need the void that you've got in your code)
    2. I'm not sure, but I think your call to show might be wrong. Move the setsize and setvisible calls to outside of the constructor

Maybe you are looking for

  • I forgot my iPhone passcode, what can I do?

    yeah so ive been trying random codes for a whole day now :L

  • Importing Stereo File to Two Mono Tracks?

    I have a stereo audio file. I'd like to put it into GB2 with one side of the stereo file as one mono track and the second side of the stereo file as a second mono track. Is there any way to do this? Thanks, Leon

  • Desc in SQL Developer behaves  slightly differently than desc in SQLPlus

    Hi All, Didn't see any posts for this, so I wanted to bring it up here. We use nls_length_semantics=char, and therefore our varchar2 cols routinely show up in products with the datalength as charlengthx4 or the actual bytelength for the col. However

  • Cancel Invoice Document MR8M-

    Hi Gurus, Good day! When I try to reverse the document # I'm getting an error message of Invoice document number cannot be processed further. Please help me regarding with this problem. Regards, Virgilio Message was edited by:         Virgilio Padios

  • Upgrade Question / Frustration

    I just left a Verizon Wireless store location and have to be honest, I was pretty frustrated with the service and their unwillingness to basically do anything other than sell me something I wasn't even interested in.  Considering the customer service