Someone please help creating comparable objects

I have been given a second part to an assignement that wants me to create a program for comparing student obejects. The assignment description and code are below. I can' t see how the find to method interlocks with the findsmallest because find smallest is already finding the smallest value. I also don't see where the new diffinitions for UMUC_Comparable goes.
In the second part of this project, you will also find the smallest element in the array, but now the array will be of UMUC_Comparable objects. It will use the compareTo method to compare objects to find the smallest one. This method will also have the name findSmallest, but will take an array of UMUC_Comparable objects. This findSmallest method will have a definition as follows:
UMUC_Comparable findSmallest(UMUC_Comparable[] array);
The findSmallest method will use the compareTo method in the UMUC_Comparable interface. You will be using it with the Student objects from module V, section III, so you do not have to rewrite the compareTo method; you can simply use the one defined in the Student object in module V.
For the second part of this project, you should:
Create a main that creates an array of Student objects, as in section III of module V. You can use the same array as defined module V. You do not have to read these objects in from a file.
Call the findSmallest method to find the smallest Student object.
Use the getName and getAverage methods in the Student object to print out the smallest object.
Note that the return from the method is a UMUC_Comparable object, not a Student object, so you must cast the returned object to a Student object before printing it out. You can do so as follows:
Student[] students ....; // Fill in the declaration // of the student array.
Student s = (Student)findSmallest(UMUC_Comparable[] array);
/* File: Student.java
* Author: Darrell Clark
* Date: December 3, 2006
* Purpose: Shows how to find the smallest Int value in an array
import java.util.*;
import java.io.*;
public class Student {
private int average;
private String name;
/* public constructor. Note that because no default
* constructor exists, Student objects will always
* be constructed with a name and an average.
public Student(String name, int average) {
this.average = average;
this.name = name;
} // end method
* return name
public String getName() {
return name;
} // end method
* return average
public int getAverage() {
return average;
} // end method
* compare to method for locating smallest value
     public static int findSmallest(int[] array) {
          int min = Integer.MAX_VALUE;
          for (int i = 1; i < (array.length); i++) {
               if (array[i] < min)
                    min = array;
          return min;
* compare student value
public int compareTo(Student student) {
return (this.average - student.average);
} // end method
     public static void main(String[] args) {
Student[] studentArray = { new Student("Tom", 87),
new Student("Cindy", 100),
new Student("Pat", 75),
new Student("Anne", 92),
new Student("Matt", 82)};
for (int i = 0; i < studentArray.length; i++) {
System.out.println(studentArray[i].name + " " +
studentArray[i].average);
} // end for
} // end method
} // end class

Were you given the UMUC_Comparable interface, or do you have to write it?
(1) In the latter case, that is where to start. It includes the method
compareTo(UMUC_Comparable). This will almost certainly return an
int - check out the API documentatuon for the Comparable interface.
(2) What I think the assignment is asking you to do is rewrite the Student
class so that it implements UMUC_Comparable.
Then you write the findSmallest(UMUC_Comparable[]) method. There is
already a static method like this in the (existing) Student class. It's anybody's
guess where this method is supposed to go - perhaps you could ask
whoever gave you the assignment. The problem is that it can't go in
UMUC_Comparable because that's an interface. And it doesn't really belong
in Student because it is a sort of utility function that deals with any
UNUC_Comparable array.
(3) Let's assume that findSmallest(UMUC_Comparable[]) goes in the
Student class. So you replace the existing findSmallest() with the new one.
The new one goes through the array using the UMUC_Comparable's
compareTo() method to find the smallest UMUC_Comparable.
(4) Finally in main() you create a test array, use the newly rewritten
findSmallest() to find the smallest Student, and print their name and
average.

Similar Messages

  • TS3406 I have a connection in the top left hand corner and can access the internet with and without internet on my iphone 5c but I can't receive and create texts and calls, someone please help have tried everything!

    I have a connection in the top left hand corner and can access the internet with and without internet on my iphone 5c but I can't receive and create texts and calls, someone please help have tried everything!

    YOu will need to contact your cell phone provider to resolve those issue, those are carrier features.

  • Can you create and print a hard cover photo album on iPhoto when you only have a iPad,  can someone please help.  Did not see the option to print.

    I am trying to create and print a hard cover photobook using iPhoto on my iPad, can this be done?  Did not see the option.  Can someone please help?

    It can't be done on the iPad using iPhoto for iOS.  You need to use iPhoto for the Mac.

  • Someone please help me!!!! out of my wits!!!!

    Hi all,
    i have the following two classes. one is a table model that in herits from DefaultTableModel. i have designed the table model to show the first row with blank values except for the run column which has a checkbox. when i call the method Add_New_Row from a button click, nothing happens. i want to add a new row to the table the same as the first. Can someone please help with this.
    public class Table_Class extends JTable
    CsgTableModel model = new CsgTableModel();
    JTable table = new JTable(model);
    JScrollPane pane = new JScrollPane(table);
    public Table_Class()
    table.setRowHeight(25);
    public JScrollPane Return_Table()
    return (pane);
    public void Add_New_Row() // add a new object row to the mission table
    ((DefaultTableModel)(table.getModel())).addRow(new Object[] {null,"","","","",new Boolean(false),""});
    public class CsgTableModel extends DefaultTableModel {
    final String[] columnNames = {"Name","Object Trajectory",
    "Type of Sensor","Signature","Sensor Trajectory",
    "Run","Status of run"};
    final Object[][] data = {{"", "","","","",new Boolean(false),""}};
    public int getColumnCount() {
    return columnNames.length;
    public int getRowCount() {
         return 1;
    public String getColumnName(int col) {
    return columnNames[col];
    public Object getValueAt(int row, int col) {
    return data[row][col];
    * JTable uses this method to determine the default renderer/
    * editor for each cell. If we didn't implement this method,
    * then the last column would contain text ("true"/"false"),
    * rather than a check box.
    public Class getColumnClass(int c) {
    return getValueAt(0, c).getClass();
    * Don't need to implement this method unless your table's
    * editable.
    public boolean isCellEditable(int row, int col) {
    //Note that the data/cell address is constant,
    //no matter where the cell appears onscreen.
    if (col < 0) {
    return false;
    } else {
    return true;
    * Don't need to implement this method unless your table's
    * data can change.
    public void setValueAt(Object value, int row, int col) {
    if (data[0][col] instanceof Integer
    && !(value instanceof Integer)) {
    //With JFC/Swing 1.1 and JDK 1.2, we need to create
    //an Integer from the value; otherwise, the column
    //switches to contain Strings. Starting with v 1.3,
    //the table automatically converts value to an Integer,
    //so you only need the code in the 'else' part of this
    //'if' block.
    try {
    data[row][col] = new Integer(value.toString());
    fireTableCellUpdated(row, col);
    } catch (NumberFormatException e) {
    } else {
    data[row][col] = value;
    fireTableCellUpdated(row, col);
    thanks for any help

    use Vectors of vectors for holding your table data, since you won't be able to increase the size of your Object[][] array when you add a new row.
    Implement your table model as follows -
    public class CsgTableModel extends DefaultTableModel {
    final String[] columnNames = {"Name","Object Trajectory",
    "Type of Sensor","Signature","Sensor Trajectory",
    "Run","Status of run"};
    Vector data = new Vector();
    public int getColumnCount() {
    return columnNames.length;
    public int getRowCount() {
    return data.size();
    public String getColumnName(int col) {
    return columnNames[col];
    public Object getValueAt(int row, int col) {
    Vector rowData = (vector) data.get(row);
    return rowData.get(col);
    public void addRow(Vector rowdata) {          
    int newRowIndex = getRowCount();
    data.add(rowdata);               
    fireTableRowsInserted(newRowIndex, newRowIndex);
    public Class getColumnClass(int c) {
    return getValueAt(0, c).getClass();
    public boolean isCellEditable(int row, int col) {
    if (col < 0) {
    return false;
    } else {
    return true;
    public void setValueAt(Object value, int row, int col) {
    Vector tempData = (Vector) data.get(0);
    if (tempData.get(col) instanceof Integer
    && !(value instanceof Integer)) {
    Vector rowData = (Vector) data.get(row);
    try {
    rowData.removeElementAt(col);
    rowData.add(col, new Integer(value.toString()));
    fireTableCellUpdated(row, col);
    } catch (NumberFormatException e) {
    } else {
    rowData.removeElementAt(col);
    rowData.add(col, value);
    fireTableCellUpdated(row, col);
    your Add_New_Row() method should now look like this -
    public void Add_New_Row() // add a new object row to the mission table {
    Vector rowVector = new Vector();
    rowVector.add("");
    rowVector.add("");
    rowVector.add("");
    rowVector.add("");
    rowVector.add("");
    rowVector.add(new Boolean(false));
    rowVector.add("");
    model.addRow(rowVector);
    table.updateUI();

  • Hi, I am wondering why my iphone won't send pictures through messages, I have MMS on and I have tried sending it with 3G on aswell and still doesn't work. Someone please help me :)

    Hi, I am wondering why my iphone won't send pictures through messages, I have MMS on and I have tried sending it with 3G on aswell and still doesn't work. Someone please help me :)

    Hey lozza567,
    Thanks for the question. I understand that you are experiencing issues sending MMS messages. The following resource may provide a solution:
    iOS: Troubleshooting Messages
    http://support.apple.com/kb/ts2755
    Issues with sending and receiving MMS
    You will need these to send and receive MMS:
    - An iPhone 3G or later.
    - iOS 3.1 or later.
    - A cellular data connection. MMS isn't available if you are using only Wi-Fi.
    - A domestic MMS plan from your cellular provider. You may need an international messaging plan to send MMS to an international contact. Contact your carrier for more information.
    - A roaming MMS when using a cellular provider's network different from your billing cellular provider's network. Learn more about roaming and contact your carrier for more information.
    To resolve issues with sending and receiving MMS, follow these steps first
    1. Go to Settings and turn airplane mode off.
    2. Go to Settings > Messages and turn MMS Messaging on.
    3. Go to Settings > Cellular and turn Cellular Data on.
    4. Go to Settings > Cellular and turn Data Roaming on if you are roaming on a cellular provider network different from your billing provider's network.
    5. Verify that you have a cellular data connection in the status bar at the top left of your iPhone.
    6. Go to Settings and turn Wi-Fi off. Open Safari and navigate to www.apple.com to verify that you have a data connection. Turn Wi-Fi back on to continue using Wi-Fi for other features. If your cellular data connection isn't available, follow these steps.
    7. Verify that you can send and receive SMS. If you are unable to send and receive SMS, see the "Issues with sending and receiving SMS" section, above.
    8. MMS may not be available while on a call. Only 3G and faster GSM networks support simultaneous data and voice calls. Learn more about which network your phone supports.
    9. Restart your iPhone.
    10. Tap Settings > General > Reset > Reset Network Settings on your iPhone.
    11. Reseat your SIM card.
    If you are still unable to send or receive MMS, follow these steps
    1. Make sure that the contact trying to message you isn't blocked in Settings > Messages > Blocked.
    2. Go to Settings > Messages and turn on group messaging if you are sending a group message.
    3. Make sure that you are using the area code with the contact's phone number. When sending messages internationally, you also need the contact's international code.
    4. Verify a "Pay as you go" MMS plan has enough available balance. Contact your carrier if unsure of your MMS plan or available balance.
    5. If the issue occurs with a specific contact or contacts, back up or forward important messages and delete your current messaging threads with the contact. Create a new message to the contact and try again.
    6. If the issue occurs with a specific contact or contacts, delete and re-create the contact from the Contacts application. Create a new message to the newly created contact and try again.
    7. Back up and restore your iPhone as new.
    8. If your carrier has recently ported your phone number, the porting process may not be complete. Contact your carrier to confirm that the porting process is complete.
    9. Contact your carrier to verify that you are provisioned to send SMS and are in an area with cellular coverage.
    10. Contact your carrier to verify that there are no blocks or filters placed on your wireless account preventing you from sending SMS.
    11. Your carrier may require APN settings to be modified to use MMS. Learn more about when you should adjust APN settings.
    Thanks,
    Matt M.

  • Please help me! I imported my pics to iphoto but I can't open them now. I can't see them on full Screen/edit them like before. All I get is a exclamation mark when I double click on them. I don't have copies, can someone please help me?

    I imported all my pics to Iphoto and I can't open/edit them now. When I double click on them, I only get an exclamation mark. Please help me I don't have copies. I tried burning them to a cd but it didn't work. Can someone please help me?

    The ! turns up when iPhoto loses the connection between the thumbnail in the iPhoto Window and the file it represents.
    What version of iPhoto? Assuming 09 or later...
    Option 1
    Back Up and try rebuild the library: hold down the command and option (or alt) keys while launching iPhoto. Use the resulting dialogue to rebuild. Choose to Rebuild iPhoto Library Database from automatic backup.
    If that fails:
    Option 2
    Download iPhoto Library Manager and use its rebuild function. This will create a new library based on data in the albumdata.xml file. Not everything will be brought over - no slideshows, books or calendars, for instance - but it should get all your albums and keywords back.
    Because this process creates an entirely new library and leaves your old one untouched, it is non-destructive, and if you're not happy with the results you can simply return to your old one. .
    Regards
    TD

  • Why isn't my email verify even if I did it so many  times then it says your email is verify for another account can  someone please help me

    I created an apple ID with iTunes gift card
    Then i signed in
    I tried to download a game and it said that
    My email is not verifyed then I to verify it but
    It said that my email is already verifyed for another email
    Can someone please help me with this problem

    Make sure there is no other account using that email. (Try going to https://appleid.apple.com/cgi-bin/WebObjects/MyAppleId.woa/ hitting Reset your password, and then enter the email address.

  • Attempting to install iTunes Version 10.5 and getting Invalid Signature. Can someone please help???

    I am attempting to install iTunes Version 10.5. I am getting the following messages...
    "Files shared by these updates" has an invalid signature. It will not be installed.
    "iTunes" has an invalid signature. It will not be installed.
    "Safari 5" has an invalid signature. It will not be installed.
    I somehow got around this annoying "invalid signature" problem before by installing the iTunes update through the Apple site.
    http://www.apple.com/itunes/download/
    When I tried that, now I get...
    "The installer encountered errors before iTunes could be configured. Errors occurred during installation. Your system has not been modified. Please run the installer again, or click Finish to Exit"
    All this to get the latest iPhone software. And every blessed time I go to Sync my iPhone, I run into iTunes issue on my Dell PC here. I guess PC and Mac just cannot play well together.
    Can someone PLEASE help me out here???
    Thanks in advance for your help.
    PSULionRP

    Hi. I also had this problem when trying to connect a new iPhone 4S & it needed iTunes 10.5. Went to the Apple website as update section of iTunes was not getting any luck - went to downloads section of Apple website & downloaded the whole iTunes 10.5 program as though I did not have it in the first place (& also downloaded the programs for Quicktime 7.7.1 & Safari 4.0.3) ie not just the upgrades. I created a restore point in my Windows XP in case it all went pear shaped & then went ahead & installed all 3 programs. Opened iTunes at the end & all my music, apps, movies were all still there & now the new iPhone 4S works perfectly with the iTunes. Hope this helps.

  • SOMEONE PLEASE HELP ME!!!  Indesign keeps crashing on Mavericks...

    I've upgraded to Mavericks (big mistake) and now InDesign and sometimes Illustrator (CS6) keeps crashing on me.  I've brought my iMac to Apple, they said i needed more RAM, bought more RAM, keeps crashing.  They reinstalled Mavericks, keeps crashing.  I've uninstalled and reinstalled Adobe CS6 (used Cleaner Tool as well), keeps crashing.  I cannot work and have spent over $600 trying to get this fixed someone please help thank you!!

    Hi
    Could you please just try to check if the application is working in a new admin account without uninstalling and reinstalling it  ,
    Also if you can check if it would work in the Safe Mode 
    Help document for safe mode : OS X Mavericks: Start up in safe mode
    I guess you know how to create a new admin account "please do not check with Pre existing account "
    Please Reply with the result and we can work further
    Regards
    J

  • Can someone please help i cant connect to itunes from my iphone 4 ,,i had an iphone 3 and when i got my iphone 4 i changed my email address for new itunes account and my old phone which hubby uses

    Can someone please help i cant connect to itunes from my iphone 4 ,,i had an iphone 3 and when i got my iphone 4 i changed my email address for new itunes account and my old phone which hubby uses is changed aswell ..for some reason i cant update my apps off m iphone & in itunes via pc it will say apps are all up to date but i have 25 apps that need updating please can someone help ,, i can download a new app but i cant update existing ones ,,,
    very frustrated iphone user !!

    Changing devices is no reason to create a new Apple ID.
    All content purchased from iTunes is permanently linked to the Apple ID it was purchased with.
    To update apps purchased with the old ID, you MUST sign in with that Apple ID.

  • Airport Card not picking up networks...Someone please help!!

    Alright heres the deal. I just bought my first MAC, a Mac Pro With 2 2.66 Xeon processors, yes this thing should fly the space shuttle(you'd think). But why does Apple not have a preinstalled Airport Card in their top of line unit? Who knows. Anyway, I went to the Apple store and purchased one and installed it, no problem. It should work, right? WRONG. My nightmare has started. The computer definitely reads that the card is there. ID and all. But I am not seeing and IP address in the dialog box/tab TCP??. I have called Apple Care to no avail, folks at the store, don't have a clue, so i thought i'd give this forum one more shot at the hopes that someone here will know how to configure this thing and get me on line. NAturally i am writing this from my trusty ol' PC...which never fails me, btw. FYI, the other two computers in my houselhold, this trusty Sony Viao and an iMAC laptop, have no problem at all picking up network signals. And folks come over all the time with their MAC laptops and never have a problem accessing our network..so why can't my MAC PRO? Is there a driver to install, and if so why did it not come in the box with the Card? Someone please help me out before i take this thing back and get a PC. I am on the verge. Thanks.
    MAC PRO   Mac OS X (10.4.7)   Self Installed Aiport Card

    Let's double-check your AirPort settings:
    To setup AirPort for High-Speed Cable Internet connectivity:
    System Preferences > Network > Show > Network Port Configurations
    - Verify that an AirPort option exists. If it does not, click "New" to create one. (Note: If you are unable to create an AirPort configuration, the AirPort card in your computer either doesn't exist or it is not recognized.)
    - Verify that AirPort is "On" (checked)
    - Verify that AirPort is at the top of the list. If it isn't, you can drag it to the top.
    Systems Preferences > Network > Show > AirPort
    AirPort tab
    - By default, join: Automatic
    TCP/IP tab
    - Configure IPv4: Using DHCP
    - Configure IPv6: Automatically or Off
    Proxies tab
    - Configure Proxies: Manually
    - Select a proxy server to configure: <All proxies should be unchecked unless you specifically require a proxy for Internet access.>
    - Exclude simple hostnames (unchecked)
    - Bypass proxy settings for these Hosts & Domains: <leave blank>
    - Use Passive FTP Mode (PASV) (checked)

  • Whenever i try to install or update my mac to OS X Yosemite it asks for my apple ID and then takes me on to a page to fill in a credit card information form. However i don't like to share information like that online can someone please help me ?

    Whenever i try to install or update my mac to OS X Yosemite it asks for my apple ID and then takes me on to a page to fill in a credit card information form. However i don't like to share information like that online can someone please help me ?

    Not really, but you did need that when you got your Apple ID.
    Creating an iTunes Store, App Store, iBooks Store, and Mac App Store account without a credit card

  • Airport problems! can someone please help?

    i've had an ibook G4 for several months now. it has been working perfectly with my belkin router up until the last month. it seems like i can rarely ever connect to the internet at home with airport like i normally would. and when i do mange to connect, it seems to go away after i open it from sleep. i've been using it at school more recently and i'm wondering if this has anything to do with it. i've tried messing around with the network settings but nothing seems to work. i have it set to connect automatically right now. i also installed adobe cs2 recently, but i can't imagine this would affect how airport works. i'm going crazy because i hate not being able to use it to get on the internet when i'm at home. can someone please help me?! thanks!
    iBook G4   Mac OS X (10.4.5)  

    Hi Aliciarules,
    Welcome to Apple Discussions
    You may want to look at this previous post. Have you created different locations (Changing the priority of your network connections?
    You may want to look at...
    Knowledge Base Document #106858, which is The Airport Troubleshooting Guide
    Knowledge Base Document #58543 on Potential sources of interference
    Jon
    Mac Mini 1.42Ghz, iPod (All), Airport (Graphite & Express), G4 1.33Ghz iBook, G4 iMac 1Ghz, G3 500Mhz, iBook iMac 233Mhz, eMate, Power Mac 5400 LC, PowerBook 540c, Macintosh 128K, Apple //e, Apple //, and some more...  Mac OS X (10.4.5) Moto Razr, iLife '06, SmartDisk 160Gb, Apple BT Mouse, Sight..

  • I miss and erased all my music off my ipad and now its freaking out. I can't get it to re-sync. Can someone please help me. I want my music back.

    Hello. I am in need of some help please. I miss and remove all music off mt ipad mini. now it won't sync or re-sync. Can someone please help me. I was also sent a message saying there was a error. Help Please

    Okay, doing my best to ignore the EXTREMELY annoying font you chose to use.
    Is there a reason why you did not create a backup of your media and other important files before switching from Vista?
    It is the users responsibility to back up their media, it is NOT Apple's responsibility.
    When you purchase CD's or DVD's, if you lose them, you repurchase them.  Same deal with digital media.
    If you have a backup of your media, simply copy the files from the backup to your computer.
    If you still have access to your old computer, simply copy the files from it to your new computer.

  • Emergency!! Someone please help me!!!!

    I created second database in the Linux box. The problem comes. Before I installed, everthing runs smoothly, client can access database through Sqlplus & OEM tools. After I created second database used scripts generated by database configuration manager, the system just don't work any more!!!
    1. After I type "svrmgrl" and "connect internal/[email protected]", the screen prompt "Insufficient priviledge".
    2. Ok, then I tried issued ORACLE_SID=db1 and following commands svrmgrl, connect internal, startup open. By using this way, I am able to start both databases. But client not able to access database any more, it always prompt "Oracle not available".
    3. And even on server console, when I type "sqlplus system/[email protected]", it return "ORACLE not available" also. If I only type "sqlplus system/manager", it works, but I only can access first database. What is going on?? HELP!! Someone please help me!!!!
    BTW, I already checked listener.ora & tnsnames.ora. I don't think that is the problem. If anyone want to see these two files, I can attach it...
    HELP!! HELP!!

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by David Wang ([email protected]):
    I created second database in the Linux box. The problem comes. Before I installed, everthing runs smoothly, client can access database through Sqlplus & OEM tools. After I created second database used scripts generated by database configuration manager, the system just don't work any more!!!
    1. After I type "svrmgrl" and "connect internal/[email protected]", the screen prompt "Insufficient priviledge".
    2. Ok, then I tried issued ORACLE_SID=db1 and following commands svrmgrl, connect internal, startup open. By using this way, I am able to start both databases. But client not able to access database any more, it always prompt "Oracle not available".
    3. And even on server console, when I type "sqlplus system/[email protected]", it return "ORACLE not available" also. If I only type "sqlplus system/manager", it works, but I only can access first database. What is going on?? HELP!! Someone please help me!!!!
    BTW, I already checked listener.ora & tnsnames.ora. I don't think that is the problem. If anyone want to see these two files, I can attach it...
    HELP!! HELP!! <HR></BLOCKQUOTE>
    Check your profile, .bash_profile and so on. Looks like you did not set new SID.
    The profile on client side need to be checked too.
    null

Maybe you are looking for

  • How Insert the input parameter to database through Java Bean

    Hello To All.. I want to store the input parameter through Standard Action <jsp:useBean>. jsp:useBean call a property IssueData. this property exist in SimpleBean which create a connection from DB and insert the data. At run time when I click on subm

  • Press colour profiles / ink density

    I am setting up press. I have been given colour profiles. I go edit convert to colour profile. I save the file and place in indesign. I make a high res pdf set to 2001 and this colour profile and my ink density is still too high. Am I not converting

  • Delete overlapping request in DTP

    Hi,        Is there an option to set "Delete overlapping request" in DTP?.

  • "noexec on" function parse errors, any alternatives?

    Hi there, I'm strugling with the noxec option which still produces sql compile errors (not a simple syntax error). Situation: We use a custom delta script pattern which stops the execution on certain conditions by setting noexec. This is working fine

  • Cisco 4003 series switch

    Hi...All. In cisco 4003 series switch i m getting error in post test its says , rtc failed, after that supervisorengineer wxx4012 LED status is Red.can any one tell me wt that means and hw to solve that problem.