Skip to content

Instantly share code, notes, and snippets.

@khayyamsaleem
Created September 3, 2017 14:36
Show Gist options
  • Save khayyamsaleem/0c3e57658162714c3a20c206394f81bc to your computer and use it in GitHub Desktop.
Save khayyamsaleem/0c3e57658162714c3a20c206394f81bc to your computer and use it in GitHub Desktop.
import java.util.Scanner;
class Client {
private float height;
private String name;
private float collarSize;
public Client(float height, String name, float collarSize){
this.height = height;
this.name = name;
this.collarSize = collarSize;
}
void setName(String name){
this.name = name;
}
String getName(){
return this.name;
}
void setHeight(float height){
this.height = height;
}
float getHeight(){
return this.height;
}
void setCollarSize(float collarSize){
this.collarSize = collarSize;
}
float getCollarSize(){
return this.collarSize;
}
public String toString(){
return "Name: " + this.getName() + "\n" +
"Height: " + Float.toString(this.getHeight()) + "\n" +
"Collar Size: " + Float.toString(this.getCollarSize());
}
public static void main(String[] args){
Scanner ns = new Scanner(System.in);
System.out.println("Hello! Create a new client.");
System.out.print("Enter client name: ");
String cname = ns.nextLine();
System.out.print("Enter client height: ");
float cheight = ns.nextFloat();
System.out.print("Enter client collar size: ");
float ccollar = ns.nextFloat();
Client c = new Client(cheight, cname, ccollar);
System.out.println(c);
}
}
@sahanshyamal
Copy link

Thank You so much for this code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment