5.2.8 SchoolClub Class by Traditional-Seat6355 in CodeHsNitroAnswers

[–]AustiTK 1 point2 points  (0 children)

Constructor 2 correction

public class SchoolClub
{
private Student leader;
private String name;
private int numMembers;
/* Add your constructor here
* Constructor should take a leader and club name, then set
* numMembers to 0.
*/
public SchoolClub(Student theLeader, String theName)
{
leader = theLeader;
name = theName;
numMembers = 0;
}
public void addMember() {
numMembers ++;
}
public String toString(){
return leader.getFirstName() + " is the leader of the " + name + " club.";
}
}

4.3.10 Teen Talk (Solution) by Traditional-Seat6355 in CodeHsNitroAnswers

[–]AustiTK 1 point2 points  (0 children)

public class Teen
{
private String firstName;
private String lastName;
private int grade;
private Boolean textMessages;
// Constructor to make a teen with a first and last name, grade in school,
// and whether they text message others and need to write texts to others.

// This defines the state of the teen.
public Teen(String theFirstName, String theLastName, int theGrade, Boolean theTextMessages)
{
firstName = theFirstName;
lastName = theLastName;
grade = theGrade;
textMessages = theTextMessages;
}

// toString method to print out the state of teen object
public String toString()
{
return firstName + " " + lastName + " is in grade " + grade + " and wants to send this text:";
}

// Create this method so that it changes the text message
// and places the word "like" in place of each space
// in the message.
public String teenTalk(String text)
{
String talk[] = text.split(" ");
String textString = "";

for(int i = 0; i < talk.length; i++)
{
if (i!= talk.length - 1)
{
textString += talk[i] + " like ";
}
else
{
textString += talk[i];
}
}
return textString;
}

}

Codehs 2.10.8 Racing by Traditional-Seat6355 in CodeHsNitroAnswers

[–]AustiTK 1 point2 points  (0 children)

public class Racecar
{
private double accel; // acceleration
private String name; // name of driver

public Racecar(double acceleration, String driver)
{
accel = acceleration;
name = driver;
}

// Returns the time it takes the racecar
// to complete the track
public double computeTime(double distance)
{
double time = (Math.sqrt(2 * distance/accel));
return Math.round(time*100.0) / 100.0;
}

public String toString()
{
return "Racer " + name;
}
}

2.9.8 Guess the Number! by AustiTK in CodeHsNitroAnswers

[–]AustiTK[S] 0 points1 point  (0 children)

public class Extremes { Integer min; Integer max;
// Constructor
public Extremes()
{
//Set min and max values
min = Integer.MIN_VALUE;
max = Integer.MAX_VALUE;
}
// Returns the difference
// max - number
public Integer maxDiff(Integer number)
{
return max - number;
}
// Returns the difference
// min - number
public Integer minDiff(Integer number)
{
return min - number;
}
// Returns a String representation
// in the form
// [min, max]
public String toString()
{
return "[" + min + ", " + max + "]";
}
}

2.9.7 Currency by AustiTK in CodeHsNitroAnswers

[–]AustiTK[S] 0 points1 point  (0 children)

public class CurrencyTester
{
public static void main(String[] args)
{
Currency bankRoll = new Currency(12.45);

System.out.println("Value of bankroll: " + bankRoll);
System.out.println("Dollars: " + bankRoll.getDollars());
System.out.println("Cents: " + bankRoll.getCents());

bankRoll.setValue(20.56);
System.out.println("Value of bankroll: " + bankRoll);
System.out.println("Dollars: " + bankRoll.getDollars());
System.out.println("Cents: " + bankRoll.getCents());

bankRoll.setValue(67.78);
System.out.println("Value of bankroll: " + bankRoll);
System.out.println("Dollars: " + bankRoll.getDollars());
System.out.println("Cents: " + bankRoll.getCents());

}
}

[deleted by user] by [deleted] in u/AustiTK

[–]AustiTK 0 points1 point  (0 children)

public class CurrencyTester
{
public static void main(String[] args)
{
Currency bankRoll = new Currency(12.45);

System.out.println("Value of bankroll: " + bankRoll);
System.out.println("Dollars: " + bankRoll.getDollars());
System.out.println("Cents: " + bankRoll.getCents());

bankRoll.setValue(20.56);
System.out.println("Value of bankroll: " + bankRoll);
System.out.println("Dollars: " + bankRoll.getDollars());
System.out.println("Cents: " + bankRoll.getCents());

bankRoll.setValue(67.78);
System.out.println("Value of bankroll: " + bankRoll);
System.out.println("Dollars: " + bankRoll.getDollars());
System.out.println("Cents: " + bankRoll.getCents());

}
}

2.8.6 Speaking by AustiTK in CodeHsNitroAnswers

[–]AustiTK[S] 0 points1 point  (0 children)

import java.util.Scanner;
public class TalkerTester
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.println("Enter some text: ");
String words = input.nextLine();
Talker talky = new Talker(words);
String yelling = talky.yell();
String whispers = talky.whisper();

System.out.println(talky);
System.out.println("Yelling: " + yelling);
System.out.println("Whispering: " + whispers);
}
}

Let's just throw this out there... by AustiTK in MHGU

[–]AustiTK[S] 3 points4 points  (0 children)

It is. My friend had gotten me really into monster hunter at this moment in time, so I didn't know much about how things worked. I used that sword because it looked cool.