How to mock static method call by constructor?

Java method that will take two integer parameters major and elective and returns a boolean value True o?

  • I am currently working on this assignment: You need to do the following: 1. Develop a method canGraduate that will take two integer parameters major and elective and returns a boolean value True or False based on the following: The method will check if a student will be able to graduate or not based on the number of credit hours he has taken in both major and elective courses. The student should have at least 44 credit hours in major courses and at least 16 credit hours in elective courses in order to graduate. 2. In your main method you need to read student data from a file (optional) or from the user which includes the student id, major, major credit hours, elective hours. The main method will call the canGraduate method for every student by passing the values read from the file. Then the main method will print a list of students who can graduate this year including the student id and major. and this is what I have come up with after multiple evenings and many many hours of TRYING to figure this out: import java.io.*; import java.util.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class CanGraduate extends JFrame { private static final int WIDTH = 550; private static final int HEIGHT = 430; private static final int maxNumberOfStudents = 10; //instance Variables private int noOfStudents; private double schoolNumber; private int displayedStudentIndex = 0; private JLabel headingL, stNameL, stIDL, noMajorCreditsL, noElectiveCreditsL, MajorL; private JTextField stNameTF, stIDTF, noMajorCreditsTF, noElectiveCreditsTF, MajorTF; private ButtonHandler bHandler; public CanGraduate() { setTitle("Student Information"); //sets the window title setSize(WIDTH, HEIGHT); Container pane = getContentPane(); //get the container pane.setLayout(null); //set the containers layout to null bHandler = new ButtonHandler(); //instantiate the button event handler //instantiate the labels headingL = new JLabel("STUDENT RECORD"); stNameL = new JLabel("Student Name ", SwingConstants.RIGHT); stIDL = new JLabel(" Student ID ", SwingConstants.RIGHT); noMajorCreditsL = new Jlabel(" Number of Credits for Major ", SwingConstants.RIGHT); noElectiveCreditsL = new JLabel(" Number of Credits for Electives ", SwingConstants.RIGHT); MajorL = new JLabel(" Students Major ", SwingConstants.RIGHT); //instantiate the text fields stNameTF = new JTextField(10); stIDTF = new JTextField(10); noMajorCredits = new JTextField(10); noElectiveCredits = new JTextField(10); MajorTF = new JTextField(10); //instantiate the text area //instantiate the buttons and register the listener exitB = new JButton ("Exit"); exitB.addActionListener(bHandler); nextB = new JButton("Next"); nextB.addActionListener(bHandler); prevB = new JButton ("Previous"); prevB.addActionListener(bHandler); firstB = new JButton ("First"); firstB.addActionListener(bHandler); lastB = new JButton ("Last"); lastB.addActionListener(bHandler); //set the size of the labels, text fields, and buttons headingL.setSize(200, 30); stNameL.setSize(100, 30); stNameTF.setSize(100, 30); stIDL.setSize(100, 30); stIDTF.setSize(100, 30); noMajorCreditsL.setSize(120, 30); noMajorCreditsTF.setSize(100, 30); noElectiveCreditsL.setSize(100, 30); noElectiveCreditsTF.setSize(100, 30); MajorL.setSize(110, 30); MajorTF.setSize(100, 30); firstB.setSize(100, 30); prevB.setSize(100, 30); exitB.setSize(100, 30); nextB.setSize(100, 30); lastB.setSize(100, 30); //set the location of the labels, text fields, and buttons headingL.setLocation(200, 10); stNameL.setLocation(20, 50); stNameTF.setLocation(120, 50); stIDL.setLocation(20, 100); stIDTF.setLocation(120, 100); noMajorCreditsL.setLocation(300, 50); noMajorCreditsTF.setLocation(420, 50); noElectiveCreditsL.setLocation(300, 100); noElectiveCreditsTF.setLocation(420, 100); MajorL.setLocation(300, 150); MajorTF.setLocation(420, 150); firstB.setLocation(20, 370); prevB.setLocation(120, 370); exitB.setLocation(220, 370); nextB.setLocation(320, 370); lastB.setLocation(420, 370); //add the labels, text fields, and buttons to the pane pane.add(headingL); pane.add(stNameL); pane.add(stNameTF); pane.add(stID); pane.add(stIDTF); pane.add(noMajorCreditsL); pane.add(noMajorCreditsTF); pane.add(noElectiveCreditsL); pane.add(noElectiveCreditsTF); pane.add(MajorL); pane.add(MajorTF); pane.add(firstB); pane.add(prevB); pane.add(exitB); pane.add(nextB); pane.add(lastB); setVisible(true); //show the window setDefaultCloseOperation (EXIT_ON_CLOSE); } //end constructor public static void main (String[] args) throws FileNotFoundException { CanGraduateP

  • Answer:

    Your kidding, right? Many hours? Did you not read what was required? public boolean canGraduate(int major, int elective) { } Have fun.

Sahra C at Yahoo! Answers Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.