Question #47370
Create a class Count with a data member current_count with proper access specifier. Create another tester class (which has main method) to instantiate two counters of Count class.
In the Count class create 2 constructors: default and parameterized constructors.
In Count class create accessors for the current_count data member
1
Expert's answer
2015-06-05T03:59:24-0400
Code(Count.java).  public class Count {       private int count_member;              /**        * Default constructor.        */       public Count() {             count_member = 0;       }              /**        * Parameterizedconstructor.        * @param count_member        */       public Count(int count_member) {             this.count_member = count_member;       }              /**        * count_memnber accessor.        */       public int get_count_member() {             return count_member;       }        /**        * count_member muttator.        */       public void set_count_member(int count_member) {             this.count_member = count_member;       }       }Code (Main.java).public class Main {       public static void main(String[] args) {             Count ct1 = new Count();             Count ct2 = new Count(1);             System.out.format("ct1.count_member: %d\n", ct1.get_count_member());             System.out.format("ct2.count_member: %d", ct2.get_count_member());       }}Input/Output.ct1.count_member: 0ct2.count_member: 1

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS