Created
September 3, 2017 14:36
-
-
Save khayyamsaleem/0c3e57658162714c3a20c206394f81bc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank You so much for this code.