Results 1 to 2 of 2
  1. #1
    sdunn21 is offline Member
    Join Date
    Jan 2014
    Posts
    1
    Rep Power
    0

    Default Don't know how to write a client class to test methods for an assignment

    Write a class encapsualting the concept of a course grade, assuming a course grade
    has the following attributes: a course name and a letter grade. Include a constructor,
    the accessor and mutator, and methods toString and equals.Write a client class
    to test all the methods in your class.

    Here is my code except for the client class any help or suggestions on this matter would be much apperiated.

    package labmodule7num57;
    import java.util.*;

    public class LabModule7Num57 {
    // Constructors//
    private String name;
    private String letterGrade;
    public LabModule7Num57 (String name,String letterGrade) {

    this.name = name;
    this.name =letterGrade;
    }



    // Setting the name of course //
    public void setName(String name) {

    this.name = name;

    }
    //Setting the lettergrade of course//
    public void setletterGrade(String letterGrade){
    this.name=letterGrade;
    }
    // Getting the name of the course//
    public String getName() {

    return name;
    }
    // Getting the name of the letter grade//
    public String getletterGrade() {

    return letterGrade;
    }
    // Returning the name of the course and the letter grade//
    public String toString() {

    return name+":"+letterGrade;

    }
    public boolean equals(Object obj){
    if (!(obj instanceof LabModule7Num57))
    return false;
    LabModule7Num57 entry = (LabModule7Num57)obj;
    return this.name.equals(entry.name) &&
    this.letterGrade.equals(entry.letterGrade);
    }
    public int hashCode(){
    int hash = 37;
    hash = hash*17 + this.name.hashCode();
    hash = hash*17 + this.letterGrade.hashCode();
    return hash;
    }


    public static void main(String[] args) {

    }
    }

  2. #2
    Daryn is offline Senior Member
    Join Date
    Oct 2012
    Posts
    176
    Rep Power
    3

    Default Re: Don't know how to write a client class to test methods for an assignment

    Can you be more specific on what you want help with
    With the right know how, anything is possible

Similar Threads

  1. Help with assignment, calling methods in same class
    By swirth123 in forum New To Java
    Replies: 2
    Last Post: 03-16-2013, 01:11 PM
  2. How to test set methods in JUnit
    By Hazza in forum New To Java
    Replies: 3
    Last Post: 02-21-2013, 10:41 AM
  3. Replies: 2
    Last Post: 02-24-2011, 03:14 AM
  4. How do you test the fastest methods?
    By MuslimCoder in forum New To Java
    Replies: 4
    Last Post: 02-09-2009, 04:34 PM
  5. How to write a Main to test this...
    By Zombie_Leg! in forum New To Java
    Replies: 9
    Last Post: 09-27-2008, 03:30 PM

Posting Permissions

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