Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Java
Help setting up a Class
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="PB, post: 546750"] i have a class called school.java and i cant figure out how to construct another class called course.java that adds 2 people to a course. Can anyone help me out on how to set up constructors and such. Here is school.java import java.text.DecimalFormat; public class School { //----------------------------------------------------------------- // Creates some Student objects, adds them to a course, and // prints them. //----------------------------------------------------------------- public static void main (String[] args) { Address school = new Address ("800 Lancaster Ave.", "Villanova", "PA", 19085); Address jHome = new Address ("21 Jump Street", "Lynchburg", "VA", 24551); Student2 john = new Student2 ("John", "Smith", jHome, school, 75, 88, 78); Address mHome = new Address ("123 Main Street", "Euclid", "OH", 44132); Student2 marsha = new Student2 ("Marsha", "Jones", mHome, school, 100, 98, 94); Course zoology = new Course("Zoology 101"); zoology.addStudent(john); zoology.addStudent(marsha); zoology.roll(); DecimalFormat formatter = new DecimalFormat("0.0#"); System.out.println(); System.out.println ("-------------------------------------"); System.out.print ("Overall Test Average: "); System.out.println (formatter.format(zoology.average())); } } [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Java
Help setting up a Class
Top