Java inheritance - subclass method override - java

I am struggling with an inheritance task in Java
I was given an Animal.java class. My homework is to create a subclass called Lion.java. One of the tasks I'm struggling with within the entire task is outputting the type of Lion it is based on the weight of the lion. This is the code for the Animal.java
public class Animal {
private int numTeeth = 0;
private boolean spots = false;
private int weight = 0;
public Animal(int numTeeth, boolean spots, int weight){
this.setNumTeeth(numTeeth);
this.setSpots(spots);
this.setWeight(weight);
}
public int getNumTeeth(){
return numTeeth;
}
public void setNumTeeth(int numTeeth) {
this.numTeeth = numTeeth;
}
public boolean getSpots() {
return spots;
}
public void setSpots(boolean spots) {
this.spots = spots;
}
public int getWeight() {
return weight;
}
public void setWeight(int weight) {
this.weight = weight;
}
public static void main(String[] args){
Lion lion = new Lion(30, false, 80);
System.out.println(lion);
}
}
This is my code for the Lion.java class so far:
public class Lion extends Animal {
String type = "";
public Lion(int numTeeth, boolean spots, int weight) {
super(numTeeth, spots, weight);
}
public String type(int weight){
super.setWeight(weight);
if(weight <= 80){
type = "Cub";
}
else if(weight <= 120){
type = "Female";
}
else{
type = "Male";
}
return type;
}
#Override
public String toString() {
String output = "Number of Teeth: " + getNumTeeth();
output += "\nDoes it have spots?: " + getSpots();
output += "\nHow much does it weigh: " + getWeight();
output += "\nType of Lion: " + type;
return output;
The problem is the output does not return the type based on the if statement above. It's probably a very simple solution but I can't seem to figure it out.

In toString method, instead of type replace with type() method.
#Override
public String toString() {
String output = "Number of Teeth: " + getNumTeeth();
output += "\nDoes it have spots?: " + getSpots();
output += "\nHow much does it weigh: " + getWeight();
output += "\nType of Lion: " + type(getWeight());
return output;

Take a good look at your Lion constructor
public Lion(int numTeeth, boolean spots, int weight) {
super(numTeeth, spots, weight);
}
This doesn't do anything for the type (your public type method).
In order to set the private type class variable you need to either call the type method in the constructor or after the object has been created but before you call the toString method. For example
public Lion(int numTeeth, boolean spots, int weight) {
super(numTeeth, spots, weight);
type(weight);
}
Note that, as pointed out in the comments, you probably would be better off handling the type directly in the setWeight method. You can do something like
#Override
public void setWeight(int weight) {
super.setWeight(weight);
type(weight);
}
and leave the constructor alone.
Taking it one step further, you could refactor your code such that the type method has no parameter (you've already set the weight member).

Related

How do you update/change a instance variable in Java? (Beginner Level)

I am new to java, and I am trying to create a method to update the instance variable age for my objects. I am getting the code to compile, but I am seeing no change in the age value. This code is part of an assignment, so I cannot change the constructors. The method I wrote to update the age (that doesn't work) is shown below. My entire code is shown below that. I am also curious if there's a way to update/change just one of my objects, but before I do that, I need the method to work for both. Any help writing this method properly would be appreciated!
public void setnewAge(int age) {
dogAge += 1;
this.dogAge = dogAge;
}
Below is my entire code (including the method I wrote to update age).
public class Dog {
//Instance Varibles
private String dogName;
private int dogAge;
private int dogWeight;
//Two Contructors (One Completely Empty)
public Dog() {
}
public Dog(String name, int age, int weight){
dogName = name;
dogAge = age;
dogWeight = weight;
}
//Getters
public String getName() { return dogName;}
public int getAge() { return dogAge;}
public int getWeight() { return dogWeight;}
//Setters
public void setName(String theName) { dogName = theName;}
public void setAge(int theAge) {dogAge = theAge;}
public void setWeight(int theWeight) {dogWeight = theWeight;}
//to(String) method
public String toString() {
return "The dogs's name is " + getName() + ", the dogs's age is " +
getAge() + ", " + "\n" + "the dogs's weight is " + getWeight() + ".";
}
public void setnewAge(int age) {
dogAge += 1;
this.dogAge = dogAge;
}
//Main Method
public static void main(String[] args) {
Dog poodle = new Dog("Bob", 5, 26);
System.out.println(poodle);
Dog lab = new Dog();
lab.setName("Steve");
lab.setAge(8);
lab.setWeight(43);
System.out.println(lab);
}
}
As Tom said, you need to actually call the function in your main function otherwise, there will be no change, and also to refine your code for your setnewAge function, try this:
public void setnewAge() {
this.dogAge = dogAge + 1;
}
Then in the main function call setnewAge() and then print your age to see the results.
Dog poodle = new Dog("Bob", 5, 26);
poodle.setnewAge() ;

Syntax on printing objects? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
Directions: http://imgur.com/kw6A0JX
I don't think I am printing out the objects correctly. My teacher helped me with the first part so I believe I am assigning them correctly. When printing them out, do I use "this" command? What is the right syntax for this type of situation?
Thank you.
public static void main(String [ ] args) {
Dog1 Rover = new Dog1("Rover", 4);
Sheep1 Wooly = new Sheep1("Wooly", 4);
Duck1 Daffy = new Duck1("Daffy", 2);
Cat1 Ketty = new Cat1("Ketty", 4);
System.out.println(name.Dog1, getHello.Dog1, isCarnivorous.Dog1, isMammal.Dog1);
System.out.println(name.Sheep1, getHello.Sheep1, isCarnivorous.Sheep1, isMammal.Sheep1);
System.out.println(name.Duck1, getHello.Duck1, isCarnivorous.Duck1, isMammal.Duck1);
System.out.println(name.Cat11, getHello.Cat1, isCarnivorous.Cat1, isMammal.Cat1);
}
Updated:
public abstract class Animal1 { //creating Animal1 which is the base and parent class, it is abstract so abstract classes can be created below
private String animalName; //defining animalName as private
public int numberOfLegs; //# of legs as public
public Animal1(final String name){ //first constructor with only assigning name
animalName = name;
}
public Animal1(final String name, final int legs){ //second constructor assigning both name and number of legs
animalName = name;
numberOfLegs = legs;
}
public String getName(){ //first getMethod for animalName
return animalName;
}
public int getLegs(){ //second getMethod for returning numberOfLegs
return numberOfLegs;
}
public boolean isMammal(){ //returning true value with boolean
return true;
}
public boolean isCarnivorous(){ //returning true value with boolean
return true;
}
public abstract String getHello(); //creating an abstract method, possible because base class is also abstract
}
public class Cat1 extends Animal1{ //child class of Animal1
public Cat1(final String name){ //Creating class constructor taking a name, within the constructor call the parent class constructor taking one argument
super(name, 4);
}
#Override
public String getHello(){ //Overriding getHello to return "Meow"
return "Meow";
}
}
public class Dog1 extends Animal1{ //another child of Dog1
public Dog1(final String name){ //Creating class constructor taking a name, within the constructor call the parent class constructor taking one argument
super(name, 4);
}
#Override
public String getHello(){ //Overriding getHello to return "Woof"
return "Woof";
}
}
public class Duck1 extends Animal1{ //third child class of Animal1
public Duck1(final String name){ //Creating class constructor taking a name, within the constructor call the parent class constructor taking one argument
super(name, 2);
}
#Override
public boolean isMammal(){ //Overriding isMammal() function to return false, as a duck is not a mammal
return false;
}
#Override
public boolean isCarnivorous(){ //Overriding isCarnivorous() function to return false as a duck is not a carnivore
return false;
}
#Override
public String getHello(){ //Overriding getHello to return "Quack"
return "Quack";
}
}
public class Sheep1 extends Animal1{ //fourth child class of Animal1
public Duck1(final String name){ //Creating class constructor taking a name, within the constructor call the parent class constructor taking one argument
super(name, 2);
}
#Override
public boolean isCarnivorous(){ //Overriding isCarnivorous() function to return false as a sheep is not a carnivore
return false;
}
#Override
public String getHello(){ //Overriding getHello to return "Baa"
return "Baa";
}
}
public static void main(String [ ] args) {
Dog1 Rover = new Dog1("Rover", 4);
Sheep1 Wooly = new Sheep1("Wooly", 4);
Duck1 Daffy = new Duck1("Daffy", 2);
Cat1 Ketty = new Cat1("Ketty", 4);
System.out.println(Rover.getName() + ", " + Rover.getHello() + ", " + Rover.isCarnivorous() + ", " + Rover.isMammal());
System.out.println(Wooly.getName() + ", " + Wooly.getHello() + ", " + Wooly.isCarnivorous() + ", " + Wooly.isMammal());
System.out.println(Daffy.getName() + ", " + Daffy.getHello() + ", " + Daffy.isCarnivorous() + ", " + Daffy.isMammal());
System.out.println(Ketty.getName() + ", " + Ketty.getHello() + ", " + Ketty.isCarnivorous() + ", " + Ketty.isMammal());
}
Your syntax is wrong. You need to refer to the variable by name, not by class. And the method comes after the object. And System.out.println() doesn't accept multiple arguments. Try this:
System.out.println(Rover.getName() + ", " + Rover.getHello() + ", " + Rover.isCarnivorous() + ", " + Rover.isMammal());
Similarly for the other lines.
You've got your syntax reversed. If these are all methods that you're calling, then they're done like Dog1.name(). If they're just public variables, you can call them like Dog1.name.
Also, a word of advice - most object instants in java follow the syntax of first word lowercase, following words uppercase (like your methods). Not crucial, but helpful to know.
Edit: Yep, it's just what the first line of this answer reads. To get the boolean from your animal class, just call them with first the object's name, then .exampleMethod().
Also, for your print statements, the println method might print the statements funny if you leave it as it is. What you can do instead is just add some strings in between like so:
System.out.println("Name: " + Dog1.getName() + ", Hello: " + Dog1.getHello()...); // rest of line excluded for brevity
The keyword this refers to the current object.
public class Test
{
public static void main(String[] args)
{
Dog1 dog = new Dog1("Rover", 4);
System.out.println(dog.name() + " " + dog.hello() + " " + dog.carnivorus() + " " + dog.mammal() + ".");
}
}
class Dog1
{
private String name;
private int age;
private String hello;
private boolean carnivorus;
private boolean mammal;
public Dog1(String name, int age)
{
this.name = name;
this.age = age;
this.hello = "woof woof";
this.carnivorus = true;
this.mammal = true;
}
public String name()
{
return this.name;
}
public String hello()
{
return this.hello;
}
public boolean carnivorus()
{
return this.carnivorus;
}
public boolean mammal()
{
return this.mammal;
}
}

Implements Comparable Missing One trait

So I'm working on a very basic code which implements Comparable comparing a painting based on year, artist and title.
However my code isn't comparing the paintings by title, just year and artist.
public class Main {
/**
* #param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Painting p1 = new Painting(Year.NINETYEIGHT, artist.ART1, title.TIT1);
Painting p2 = new Painting(Year.NINETYEIGHT, artist.ART1, title.TIT2);
System.out.println("p1: " + p1.toString());
System.out.println("p2: " + p2.toString());
if(p1.compareTo(p2)> 0){
System.out.println(p1.toString() + " beats " + p2.toString());
} else if(p1.compareTo(p2) < 0){
System.out.println(p2.toString() + " beats " + p1.toString());
} else{
System.out.println("Same Everything");
}
}
}
public enum Year {
NINETYSEVEN, NINETYEIGHT, NINETYNINE, TWOTHOUSAND
}
public enum artist {
ART1, ART2, ART3,
}
public enum title {
TIT1, TIT2,TIT3,
}
public class Painting implements Comparable {
private title title;
private Year year;
private artist artist;
public Painting(Year y, artist a, title t) {
title = t;
year = y;
artist = a;
}
#Override
public int compareTo(Object o) {
//compare values
Painting other = (Painting) o;
int yearCompare = this.year.compareTo(other.year);
int artistCompare = this.artist.compareTo(other.artist);
if (yearCompare == 0) {
//same year, compare artist
return this.artist.compareTo(other.artist);
} else if (artistCompare == 0) {
return this.title.compareTo(other.title);
} else {
return yearCompare;
}
}
#Override
public String toString() {
return title.name() + " by " + artist.name() + " produced " + year.name();
}
}
Dang. Slow by just a few seconds. Haha. I came up with the same solution as shmosel.
public int compareTo(Painting other) {
int yearCompare = year.compareTo(other.year);
if (yearCompare != 0)
return yearCompare;
int artistCompare = artist.compareTo(other.artist);
if (artistCompare != 0)
return artistCompare;
return title.compareTo(other.title);
}
One difference. I would consider changing your class header. Specifically, I would change:
public class Painting implements Comparable
to:
public class Painting implements Comparable<Painting>
This way, instead of using the "raw" Object type, you're Painting class's compareTo() method signature will become:
public int compareTo(Painting o)
In other words, you don't have to cast or worry about checking if an argument is an instance of Painting!
Your if-else logic is flawed in several ways. It should more look like this:
int yearCompare = this.year.compareTo(other.year);
if (yearCompare != 0) {
return yearCompare;
}
int artistCompare = this.artist.compareTo(other.artist);
if (artistCompare != 0) {
return artistCompare;
}
return this.title.compareTo(other.title);
On a side note, you should generics and avoid casting:
public class Painting implements Comparable<Painting> {
#Override
public int compareTo(Painting other) {
// no casting necessary
}
}

Java Polymorphic method

I am currently finishing a University practice exam in the run up to my exam in the summer. Below is the code which I have completed so far:
I am struggling with one of the parts of the assignment. What it asks me to do is: "In the tester02, create a method called startRobot, which will be a polymorphic method. This method will accept an object of type Robot and a Scanner object. The purpose of the method is to start the robot, get the robot to undertake a task method(you must run the two versions of the doTask method here) and then to stop the robot."
so basically it asks me to create the polymorphic method and call it twice, first time passing the EntertainmentRobot into it and then the second time HumanStudyRobot. I am not sure how to set this up in the tester as I am just receiving errors when trying to write the code. I'm not really familiar with polymorphic methods / polymorphism either.
Any help at all would be much appreciated!
package Program;
import java.util.Scanner;
public abstract class Robot {
//instance variables
protected double EnergyUnitsRequired;
protected double height;
protected String manufacturer;
protected String name;
protected String purpose;
protected double weight;
protected double energy;
//constructor
public Robot(String name, double height, double weight, String manufacturer) {
super();
this.EnergyUnitsRequired = 0.25;
this.height = height;
this.manufacturer = manufacturer;
this.name = name;
this.purpose = "The robot's purpose needs to be provided";
this.weight = weight;
this.energy = 0.0;
}
//accessors & mutators
public double getEnergyUnitsRequired() {
return EnergyUnitsRequired;
}
public double getHeight() {
return height;
}
public String getManufacturer() {
return manufacturer;
}
public String getName() {
return name;
}
public String getPurpose() {
return purpose;
}
public double getWeight() {
return weight;
}
public double getEnergy() {
return energy;
}
public void setEnergyUnitsRequired(double energyUnitsRequired) {
EnergyUnitsRequired = energyUnitsRequired;
}
public void setHeight(double height) {
this.height = height;
}
public void setManufacturer(String manufacturer) {
this.manufacturer = manufacturer;
}
public void setName(String name) {
this.name = name;
}
public void setPurpose(String purpose) {
this.purpose = purpose;
}
public void setWeight(double weight) {
this.weight = weight;
}
//methods
public abstract void start();
public abstract void stop();
public abstract void doTask();
public abstract void doTask(Scanner input);
public void energyConsumption() {
System.out.println("The robot: " + getName() + " has: " + getEnergy() + " to begin with.");
double priorEnergy = getEnergy();
energy = energy - energyRequired(); //the variable energyRequired should be returned from the energyRequired method below this method.
System.out.println("My energy has depleted by the following amount: " + (priorEnergy - energy) + " units.");
System.out.println("My energy is now at: " + energy + " units.");
}
public double energyRequired() {
double energyRequired = (EnergyUnitsRequired * weight);
return energyRequired;
}
public void regenerate() {
energy = getEnergy() + (getWeight() * 2);
System.out.println("More energy is being generated for the robot.");
}
}
package Program;
import java.util.Scanner;
public class HumanStudyRobot extends Robot {
//instance variables
public HumanStudyRobot(String name, double height, double weight, String manufacturer) {
super(name, height, weight, manufacturer);
this.energy = 30.0;
}
#Override
public void start() {
System.out.println("This is a Human Study Robot");
System.out.println("The robot has started studying.");
}
#Override
public void stop() {
System.out.println("The robot has finished studying.");
}
#Override
public void doTask() {
study();
}
#Override
public void doTask(Scanner input) {
// TODO Auto-generated method stub
}
public void study() {
if (energy >= energyRequired()) {
energyConsumption();
}
else
if (energy < energyRequired()) {
System.out.println("The robot does not have sufficient energy.");
regenerate();
System.out.println("................");
System.out.println("The robot has finished regenerating");
}
}
public String toString() {
return "I AM A HUMAN STUDY ROBOT : \nThe details of the entertainment robot are below:\n"
+ "Name : " + getName() + "\nWeight: " + getWeight() + "\nHeight: "
+ getHeight() + "\nManufacturer : " + getManufacturer() + "\nPurpose : "
+ getPurpose();
}
}
package Program;
import java.util.Scanner;
import org.omg.Messaging.SyncScopeHelper;
public class EntertainmentRobot extends Robot {
//constructor
public EntertainmentRobot(String name, double height, double weight, String manufacturer) {
super(name, height, weight, manufacturer);
this.energy = 10.0;
this.EnergyUnitsRequired = 0.75;
}
#Override
public void start() {
System.out.println("This is an Entertainment Robot. \n The robot has started entertaining.");
}
#Override
public void stop() {
System.out.println("The Entertainment RObot has finsihed entertaining");
}
#Override
public void doTask() {
}
#Override
public void doTask(Scanner input) {
play();
}
public void talk() {
}
public void play () {
System.out.println("How many times would you like to play?");
if (getEnergy() >= energyRequired() ) {
energyConsumption();
}
else
if (getEnergy() < energyRequired()) {
System.out.println("The robot does not have sufficient energy to play.");
regenerate();
System.out.println("The robot is regenerating");
System.out.println(".........................");
System.out.println("The robot has finished regenerating!");
}
}
public String toString() {
return "\nI AM AN ENTERTAINMENT ROBOT \nThe details of the entertainment robot are below: \n" +
"Name : " + getName() + "\nHeight: " + getHeight() + "\nWeight: " + getWeight() + "\nManufacturer: " +
getManufacturer() + "\nPurpose: " + getPurpose();
}
}
package Program;
import java.util.Scanner;
public class Tester02 {
public static void main(String[] args) {
HumanStudyRobot HumanStudyRobot1 = new HumanStudyRobot("HRP", 1.5, 58.0, "Kawada Industries");
HumanStudyRobot1.setPurpose("Study into human movement and perform a wide range of tasks.");
/*
System.out.println(HumanStudyRobot1.toString());
HumanStudyRobot1.start();
HumanStudyRobot1.study();
HumanStudyRobot1.stop();*/
public void startRobot(Robot, Scanner input){
}
EntertainmentRobot EntertainmentRobot1 = new EntertainmentRobot("QRIO", 0.6, 7.3, "SONY");
EntertainmentRobot1.setPurpose("To live with you, make life fun and make you happy.");
System.out.println(HumanStudyRobot1.toString());
System.out.println(EntertainmentRobot1.toString());
}
}
First observation: your startRobot method signature is invalid, change it to
public void startRobot(Robot robot, Scanner input){
}
Second observation: move the method declaration outside of the main method.
Third observation: call startRobot from the main method with your robot and scanner parameters.
startRobot(EntertainmentRobot1, /*your scanner*/);
startRobot(HumanStudyRobot1, /*your scanner*/);
Since both classes extend the Robot class - they can be passed to the startRobot method. For further reading on this topic, consult the Oracle Documentation.
There's nothing wrong with the code here. Since you don't understand polymorphism principles I think you need to work on that; 3 robot classes
extend Robot class which is an abstract class, subclasses must override
super classes abstract methods. In your case the abstract methods are
public abstract void start();
public abstract void stop();
public abstract void doTask();
public abstract void doTask(Scanner input);
Since all robot classes are subclasses you can do something
like this
Robot humanrobot = new HumanStudyRobot("parameters...");
Robot entertainment = new EntertainmentRobot("parameters");
public void startRobot(Robot robot, Scanner input){
robot.dotask();
}
startRobot(humanrobot, scanner);
startRobot(entertainment, scanner);
im almost certain im on the same course as you, as im doing the exact same question, anyway after looking at what the people above have said, I got this working by doing this:
public static void main(String[] args) {
EntertainmentRobot jim = new EntertainmentRobot(0.6, "SONY", "QRIO", "To live with you, make life fun and make you happy", 7.3);
HumanStudyRobot jeff = new HumanStudyRobot(1.5, "Kawada Industries", "HRP", "Study into human movement and perfrom a wide range of tasks", 58.0);
//System.out.println(jim);
//System.out.println(jeff);
//EntertainmentRobot jim = robot();
Scanner input = new Scanner(System.in);
startRobot(jim, input);
startRobot(jeff, input);
}
public static void startRobot(Robot robot, Scanner input) {
/*
* POLYMORPHIC METHOD
* Accept an object of type robot
* Scanner object
* Start the robot
* Get robot to undertake a task
* stop the robot
*/
robot.start();
robot.doTask();
robot.stop();`enter code here`
}
}

How do I print using toString using inheritance in Java

public class StuTest2
{
public static final int NUMBER_OF_STUDENTS = 7;
public static void main(String[] args)
{
Student[] stus = new Student[NUMBER_OF_STUDENTS];
// Student has ID, name, and GPA
stus[0] = new Student(123, "Suzy", 3.9);
// Default for missing GPA will be 9.99 "special value
stus[1] = new Student(234, "Tom");
// Default name will be "Student #xxx" where
// "xxx" is the actual ID number
stus[2] = new Student(456);
// A grad student also has a thesis topic
stus[3] = new GradStudent(567, "Fred", 3.8, "Java");
// Default thesis topic is "Undecided"
stus[4] = new GradStudent(678, "Staci", 3.1);
// Doctoral students earn a stipend
stus[5] = new DoctoralStudent(789, "Mandy", 4.0, "Databases", 3550.00);
// If missing, the default stipend is $3000.00
stus[6] = new DoctoralStudent(890, "Ned", 3.7, "Cisco Networking");
// Inside the loop, the toString method is called for each
// student. All graduate students show the word "Graduate" in
// front of the output from this method.
for(Student stu : stus)
{
}
}
}
class Student
{
private int id;
private String name;
private double gpa;
public Student(int i, String n, double g)
{
id = i;
name = n;
gpa = g;
}
public Student(int i)
{
this(i, "Student #" + i);
}
public Student(int i, String n)
{
this(i, n, 9.99);
}
public int getId()
{
return id;
}
public String getName()
{
return name;
}
public double getGPA()
{
return gpa;
}
public String toString()
{
return System.out.println(stus.getId+", " + stus.getName
+ ", " + stus.getGPA);
}
}
class GradStudent extends Student
{
private String topic;
public GradStudent(int i, String n, double g, String t)
{
super(i, n, g);
topic = t;
}
public GradStudent(int i, String n, double g)
{
this(i, n, g, "Undecided");
}
public String getTopic()
{
return topic;
}
public String toString()
{
return super.getTopic();
}
}
class DoctoralStudent extends GradStudent
{
private double stip;
public DoctoralStudent(int i, String n, double g, String t, double s)
{
super(i, n, g, t);
stip = s;
}
public DoctoralStudent(int i, String n, double g, String t)
{
this(i, n, g, t, 3000.00);
}
public double getStip()
{
return stip;
}
public String toString()
{
return super.getStip();
}
}
I'm trying to print out while using the return super.toString(), but Iget errors saying cannot find symbol for stus, but I have it right before starting the student class. What gives? ps, sorry for the bad closings, trying to meet standards on here lol
Your "stus" variable is only in scope inside the main() method, so you can't access it outside of that method. Furthermore, "stus" is an array, so it doesn't even make sense to call getId on it. Further, notice that getId refers to a variable since it doesn't have parenthesis after it.
Keep in mind that in your toString() method, you're already "inside" a Student Object, so you can just call the getId() function directly:
public String toString()
{
return getId() +", " + getName() + ", " + getGPA();
}
Also note that I've removed the System.out.println() function in your toString method, since it doesn't return anything and therefore doesn't make sense to return anyway.
You've got a lot of incorrect syntax in your code, and I highly recommend starting much smaller. You'll have much better luck if you develop your program incrementally instead of trying to do the whole thing in one shot. I recommend starting over and compiling and testing with every single line you add.

Categories

Resources