Legion of Learners
www.lol-101.com
Home
Classrooms
Courses
About Us
Executive Team
Board Members
Resources
More
Use tab to navigate through the menu items.
Log In
Forum Comments
1-3 Analyzing String and Scanner to understand instances
In AP Computer Science A
icicle.bear212
Aug 26, 2021
0
0
1-1 What are classes and objects?
In AP Computer Science A
icicle.bear212
Aug 18, 2021
The repl servers were really slow so I just did everything on a seperate IDE and copy pasted. 1) The fish one: public class Main { public static void main(String[] args){ Fish fish1 = new Fish(); Fish fish2 = new Fish(); fish1.name = "clownfish"; fish1.colour = "red"; fish1.weight = "1 gram"; fish1.lifespan = 10; //years fish1.watertype = "Salt"; fish1.price = 20.00; fish2.name = "insert fish name"; fish2.colour = "turquoise"; fish2.weight = "2g"; fish2.lifespan = 10000; //years fish2.watertype = "Blue Gatorade"; fish2.price = 10000000.00; System.out.println(fish1.name); System.out.println(fish2.name); } } public class Fish { String name; String colour; String weight; int lifespan; String watertype; double price; } 2) public class Main { public static void main(String[] args){ City city = new City(); Tree type = new Tree(); city.name = "New York City"; city.population = 8200000; type.name = "Oak"; type.height = 5; type.radius = 10; type.bears_fruits = true; } } public class City { String name; int population; } public class Tree { String name; int height; // feet int radius; // inches boolean bears_fruits; }
0
0
i
icicle.bear212
0
Followers
0
Following
Follow
Following icon
More actions
Profile
Forum Comments
Forum Posts
More
Use tab to navigate through the menu items.