0% found this document useful (0 votes)
48 views4 pages

Opps Lab Assignment 1

This document describes an assignment to implement a Participant class for a dance club audition. The Participant class is to have attributes like name, contact number, branch, and a unique registration ID. The registration ID is generated from a static counter variable that is incremented each time. The document provides the class structure, method descriptions, sample input/output, and starter code for the Participant and Tester classes to test the implementation.

Uploaded by

AL HUSSAIN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views4 pages

Opps Lab Assignment 1

This document describes an assignment to implement a Participant class for a dance club audition. The Participant class is to have attributes like name, contact number, branch, and a unique registration ID. The registration ID is generated from a static counter variable that is incremented each time. The document provides the class structure, method descriptions, sample input/output, and starter code for the Participant and Tester classes to test the implementation.

Uploaded by

AL HUSSAIN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Assignment 2

Name of Student: Al-Hussain Hakim Shaikh

Batch: B1 Branch: CS Roll No: 08

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-Participant

 counter: int
 registrationId: String
 name: String
 contactNumber: long
 branch: String

o C
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 D10001 and branch is: Computer


Hi Sayli! Your registration id is D10002 and branch is: Mechanical
Add your code here

public class Tester {


public static void main(String[] args) {

Participant participant1 = new Participant("Akshay",


1234567889L, "Computer");

Participant participant2 = new Participant("Anish Bonde ",


1988612300L, "Computer ");

//Create two more instances of Participant Class

Participant[] participants = { participant1, participant2


};

for (Participant participant : participants) {

System.out.println("Hi "+participant.getName()+"! Your


registration id is "+participant.getRegistrationId()+"and branch is:
"+participant.getBranch());

//Print participant’s branch

}
}

//Another class named Participation

public class Participant {

static int counter;


private String registrationId;
private String name;
private long contactNumber;
private String branch;

public Participant(String name,long contactNumber,String branch){


super();
this.name=name;
this.contactNumber=contactNumber;
this.branch=branch;
registrationId="D"+counter;
counter++;

static{
counter=1001;
}

public int getCounter() {


return counter;
}

public void setCounter(int counter) {


Participant.counter = counter;
}

public String getRegistrationId() {


return registrationId;
}

public void setRegistrationId(String registrationId) {


this.registrationId = registrationId;
}

public String getName() {


return name;
}

public void setName(String name) {


this.name = name;
}

public long getContactNumber() {


return contactNumber;
}

public void setContactNumber(long contactNumber) {


this.contactNumber = contactNumber;
}

public String getBranch() {


return branch;
}

public void setBranch(String branch) {


this.branch = branch;
}

Expected Output:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy