Skip to content

Instantly share code, notes, and snippets.

@yohaneowo
Created January 5, 2024 14:26
Show Gist options
  • Select an option

  • Save yohaneowo/edb4a6247a5e9ec7cf5eb9e70eb25dcf to your computer and use it in GitHub Desktop.

Select an option

Save yohaneowo/edb4a6247a5e9ec7cf5eb9e70eb25dcf to your computer and use it in GitHub Desktop.
GymClass.java
import java.util.Scanner;
public class GymClass {
private String classType;
private String equipmentRenting;
private String danceType;
private String vantilation;
private String className;
private String classLevel;
private int classHours;
private String instructureName;
private static int reservationID;
public static void resetReservationID(){
reservationID = 0;
}
public GymClass(String classType, String className, String classLevel, String instructureName, int classHours, String equipmentRenting, String danceType, String vantilation){
setClassType(classType);
this.className = className;
this.classLevel = classLevel;
this.instructureName = instructureName;
this.classHours = classHours;
this.equipmentRenting = equipmentRenting;
this.danceType = danceType;
this.vantilation = vantilation;
reservationID++;
}
public int getReservationID(){
return this.reservationID;
}
public void setClassType(String classType){
switch(classType){
case "Y":
this.classType = "Yoga";
break;
case "I":
this.classType = "Indoor-cycling";
break;
case "D":
this.classType = "Dance";
break;
default:
this.classType = "Invalid class type";
break;
}
}
public String printSpesificClassOption(){
switch(this.classType){
case "Yoga":
return "Please enter the equipment renting for the Yoga class: ";
case "Indoor-cycling":
return "Please enter the Vantilation for the Yoga class: ";
case "Dance":
return "Please enter the type of the dance class: ";
default:
return "Invalid class type";
}
}
public void setEquipmentRenting(String equipmentRenting){
this.equipmentRenting = equipmentRenting;
}
public void setDanceType(String danceType){
this.danceType = danceType;
}
public void setVantilation(String vantilation){
this.vantilation = vantilation;
}
public void setSpesificClassOption(String classSpesificOption){
switch(this.classType){
case "Yoga":
this.setEquipmentRenting(classSpesificOption);
break;
case "Indoor-cycling":
this.setVantilation(classSpesificOption);
break;
case "Dance":
this.setDanceType(classSpesificOption);
break;
default:
break;
}
}
public void setClassName(String className){
this.className = className;
}
public String getClassType(){
return classType;
}
public void setClassLevel(String classLevel){
this.classLevel = classLevel;
}
public void setClassHours(int classHours){
this.classHours = classHours;
}
public String getClassName(){
return this.className;
}
public void setInstructureName(String instructureName){
this.instructureName = instructureName;
}
public String getSpesificClassOption(){
switch(this.classType){
case "Yoga":
return this.equipmentRenting;
case "Indoor-cycling":
return this.vantilation;
case "Dance":
return this.danceType;
default:
return "Invalid class type";
}
}
public String getClassLevel(){
return this.classLevel;
}
public int getClassHours(){
return this.classHours;
}
public String getInstructureName(){
return this.instructureName;
}
public int getSpesificClassOptionFee(){
switch(this.classType){
case "Yoga":
if(this.equipmentRenting.equals("Yes")){
return 100;
}
else{
return 0;
}
case "Indoor-cycling":
if(this.vantilation.equals("Yes")){
return 100;
}
else{
return 0;
}
case "Dance":
if(this.danceType.equals("Zumba")){
return 0;
}
else if(this.danceType.equals("Indian")){
return 50;
}
default:
return 0;
}
}
public int getClassFee(){
switch(this.classType){
case "Yoga":
System.out.println("hey");
if(this.classLevel.equals("basic")){
return 300;
}else if (this.classLevel.equals("moderate")){
return 500;
}else if (this.classLevel.equals("one-on-one")){
return 1000;
}
case "Indoor-cycling":
if(this.classLevel.equals("basic")){
return 270;
}else if (this.classLevel.equals("moderate")){
return 470;
}
case "Dance":
if(this.classLevel.equals("basic")){
return 250;
}else if (this.classLevel.equals("moderate")){
return 450;
}
default:
return 0;
}
}
public String getClassReservationInfo(){
return String.format("Gym Class Reservation%n%s class, %s, %d hours, with teacher %s.%nCost: $%d",this.className,this.classLevel,this.classHours,this.instructureName,(this.getClassFee()*this.classHours ) + this.getSpesificClassOptionFee());
}
public static void main(String[] Args){
// Scanner input = new Scanner(System.in);
// System.out.print("Please enter the type of the gym class (Y for Yoga, I for Indoor-cycling, D for Dance): ");
// GymClass gymClass = new GymClass();
// String classTypeInput = input.nextLine();
// gymClass.setClassType(classTypeInput);
// System.out.printf("%s", gymClass.printSpesificClassOption());
// String classSpesificOption = input.nextLine();
// gymClass.setSpesificClassOption(classSpesificOption);
// // System.out.printf("The type of the class is %s and the spesific option is %s", gymClass.getClassType(), gymClass.getSpesificClassOption());
// System.out.print("Please enter the name of the class: ");
// String classNameInput = input.nextLine();
// gymClass.setClassName(classNameInput);
// // System.out.printf("The name of the class is %s", gymClass.getClassName());
// System.out.print("Please enter the level of the class: ");
// String classLevelInput = input.nextLine();
// gymClass.setClassLevel(classLevelInput);
// System.out.print("Please enter the number of hours for the reservation: ");
// int hours = input.nextInt();
// gymClass.setClassHours(hours);
// input.nextLine();
// System.out.print("Please enter the instructor’s name: ");
// String instructorNameInput = input.nextLine();
// gymClass.setInstructureName(instructorNameInput);
// System.out.printf("%s", gymClass.getClassReservationInfo());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment