Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Assignment-1 Name of Student: Waghule Shubham Kalyan Batch: B3 Branch: Roll No.: 94 Problem Statement

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Assignment-1

Name of Student: Waghule Shubham Kalyan

Batch: B3 Branch: CS-D Roll No.: 94

Problem Statement
A VIT Melange committee is conducting auditions to admit interested
candidates. You need to implement a Participant class for the dance club
based on the class diagram and description given below.

C-Participants

 counter: int
 registrationId: String
 name: String
 contactNumber: long
 branch: String
C
o Participant(name:String,contactNumber:long,branch:String)
o getRegistrationId(): String
o getCounter(): int
o setCounter(counter:int):void
o getName():String
o setName(name:String):void
o getContactNumber():long
o setContactNumber(contactNumber:long):void
o getBranch():String
o setBranch(branch:String):void

Method Description
Partcipant(String name, long contactNumber, String branch)
 Initialize the name, contactNumber and branch instance variables
appropriately with the values passed to the constructor.
 Generate the registrationId using the static variable counter. 
 The value of registrationId should start from 'D1001' and the
numerical part should be incremented by 1 for the subsequent
values. 
 Initialize the counter in static block.
Implement the appropriate getter and setter methods.
Test the functionalities using the provided Tester class. Create two or
more Participant objects and validate that the values of the member
variables are proper.
Sample Input and Output
For constructor
Input
For first Participant object

Parameters Values
name Rohit
contactNumber 1234567889
branch Computer

For second Participant object

Parameters Values
name Sayli
contactNumber 1988612300
branch Mechanical

Expected Output

Hi Rohit! Your registration id is D1001


Hi Sayli! Your registration id is D1002

public class Participants1


{
    private String name,branch;
    static String registrationID;
    static int counter;
    private long contactNumber;
   
   Participants1(String name, long contactNumber,String branch)
   {
       this.name=name;
       this.contactNumber=contactNumber;
       this.branch=branch;
   }
   
    static {
         counter = 1001;
    }
   
    public String getRegistrationID()
    {
        registrationID=Integer.toString(counter);
        counter = counter + 1;
        return registrationID;
       
    }
   
    public void setName(String name)
    {
        this.name=name;
    }
    public String getName()
    {
        return name;
    }
   
    public void setContactNumber(long contactNumber)
    {
        this.contactNumber=contactNumber;
    }
    public long getContactNumber()
    {
        return contactNumber;
    }
    public void setBranch(String branch)
    {
        this.branch=branch;
    }
    public String getBranch()
    {
        return branch;
    }
   
    public void display()
    {
        System.out.println("Hi " + getName() + "! Your Registration ID is D" +
getRegistrationID());
    }
           
}
class MainMethod
{
    public static void main(String[] args)
    {
       
           Participants1 p = new Participants1("Rohit", 1234567889,
"Computer");
           Participants1 p1 = new Participants1("Sayli",1988612300,
"Mechanical");

           p.display();;
           p1.display();
    }
}
Results:
Actual Output

You might also like