Hi everyone, please help me with this homework For this project, you will create
ID: 638469 • Letter: H
Question
Hi everyone, please help me with this homework
For this project, you will create a text-based game. The game will display a welcome message, present a problem and make a simple calculation and display the results.
Read the Style Guide before beginning this project.
Minimum Requirements:
Create a program called gork. Your program must have separate functions to handle each of these requirements:
welcome function to welcome the player (4 points)
Your output might look similar to the following. Your output may differ in the text that is displayed, the formatting of the text and the actual values that are calculated as long as the game works as described above. The example below displays the results when option 2 is selected
Explanation / Answer
import java.util.Scanner;
public class Gork {
private static double team0;
private static double team1;
private static double assist;
public static double getTeam0() {
return team0;
}
public static void setTeam0(double team0) {
Gork.team0 = team0;
}
public static double getTeam1() {
return team1;
}
public static void setTeam1(double team1) {
Gork.team1 = team1;
}
public static double getAssist() {
return assist;
}
public static void setAssist(double assist) {
Gork.assist = assist;
}
public static double getTanks() {
return tanks;
}
public static void setTanks(double tanks) {
Gork.tanks = tanks;
}
private static double tanks;
public static void welcome(String name){
System.out.println("Welcome to the planet Gork!");
System.out.println("@Copyright 2015");
System.out.println("Created by "+name);
System.out.println("You are in charge of a team of researchers on the largest moon of planet Gork."
+" "+ "One team member finds toxic mineral. The toxic material begins to corrode the oxygen tanks."
+" "+ "Oxygen levels begin to drop.");
}
public static void main(String[] args) {
welcome("Jay");
System.out.println(" "+"Please enter the number of team members for the initial team of researchers--->");
Scanner sc=new Scanner(System.in);
setTeam0(sc.nextDouble());
int choice;
do{
System.out.println("1. Make an emergency launch to return to base.");
System.out.println("2. Secure the area with non-corrosive shielding from the lunar vehicles and "+" "+" request an emergency rescue for the number of team members with corroded oxygen tanks.");
System.out.println("3. Request emergency resupply of non-corrosive oxygen tanks from base.");
System.out.println("Please enter your choice--->"+" ");
choice =sc.nextInt();
switch (choice) {
case 1:
System.out.println("The toxic material has corroded the launch gear and the launch exploded.");
break;
case 2:
System.out.println("Please enter the number of team members to be evacuated--->");
setTeam1(sc.nextDouble());
double tanksRequired=getTeam0()-getTeam1();
setTanks(tanksRequired);
System.out.println(tanksRequired+" tanks required for the team members.");
break;
case 3:
System.out.println("Please enter the number of requested team members to assist team0--->");
setAssist(sc.nextDouble());
double totalTanksRequired=getTeam0()+getTeam1();
setTanks(totalTanksRequired);
System.out.println(totalTanksRequired+" non corrosive tanks required for the team members."+" ");
break;
default:
System.out.println("You have been eaten by a Grue.");
break;
}
}while(choice!=0);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.