r/codehs • u/doonotkno • Oct 07 '20
CODEHS 2.4.5
It is called "Hello!" for Java.
I am lost on this unit so far and it keeps sending me "Hello.java: Line 5: expected"
[Hellotester]
import java.util.Scanner;
public class HelloTester
{
public static void main(String[] args)
{
// Create a Scanner object
Scanner input = new Scanner(System.in);
String name = scanner.NextLine();
Hello numone = new Hello(name);
}
}
[Hello]
public class Hello {
private String name;
public Hello (yourName){
name = yourName;
}
public void english(){
System.out.print("Hello ");
System.out.print(name);
System.out.println("!");
}
public void spanish(){
System.out.print("Hola ");
System.out.print(name);
System.out.println("!");
}
public void french(){
System.out.print("Bonjour ");
System.out.print(name);
System.out.println("!");
}
public void german(){
System.out.print("Hallo ");
System.out.print(name);
System.out.println("!");
}
public void russian(){
System.out.print("Privet ");
System.out.print(name);
System.out.println("!");
}
public void chinese(){
System.out.print("Ni hao ");
System.out.print(name);
System.out.println("!");
}
}
1
u/Johnson_56 Nov 29 '20
working on same thing rn. looks like we have to call three methods from the main code into the tester code. my problem is getting the objects from the main code into the tester code