java - Creating a testing class -


i extremely new java forgive me if not asking question correctly. have assignment asking me:

"test accessors , mutators in class called student_testing. first create student object, set value using mutator, , print value screen. repeat each of variables. copy , paste entire student_testing class."

so have main class this:

public class main {      public static void main(string[] args) {         student student1 = new student();         student student2 = new student("joe", 123);          int id = student1.getstudentid();         string name = student1.getname();         system.out.println("id 1: " + id);         system.out.println("name 1: " + name);          int id2 = student2.getstudentid();         string name2 = student2.getname();         system.out.println("id 2: " + id2);         system.out.println("name 2: " + name2);     } } 

and have have class called student this:

public class student {      private string name;     private int student_id;     private double balance;      public student() {         name = "";         student_id = 0;         balance = 0.0;     }      public student(string input_name, int id) {         name = input_name;         student_id = id;     }      public string getname() {         return name;     }      public int getstudentid() {         return student_id;     }      public void setstudentid(int number) {         student_id = number;     }      public void deposit(double amount) {         balance = balance + amount;     } } 

i have no clue how supposed make student_testing class , create object student. errors every time.

is student_testing class created other classes have? , how supposed create new object student when have student class in different class?

like said complete beginner when come java, if explained in simplest terms possible great! thanks!

public class main {      public static void main(string[] args) {         student_testing.test();     } }  public class student_testing {      public static void test(){         student student1 = new student();         student student2 = new student("joe", 123);         int id = student1.getstudentid();         string name = student1.getname();         system.out.println("id 1: " + id);         system.out.println("name 1: " + name);         int id2 = student2.getstudentid();         string name2 = student2.getname();         system.out.println("id 2: " + id2);         system.out.println("name 2: " + name2);     } }  public class student {     //student class stuff... } 

here created new class called student_testing. in class, created static method called test(). stuff inside test() function same in original code.

note similarity between student_testing , main class?

we can call test method main function doing student_testing.test();


since still beginner, it's important ask follow questions.
i highly encourage read through , understand thoroughly


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -