Code Monkey home page Code Monkey logo

head-first-java-cliffsnotes-example's Introduction

gillianfloyd2001

head-first-java-cliffsnotes-example's People

Contributors

natec425 avatar

Watchers

 avatar

head-first-java-cliffsnotes-example's Issues

Chapter 2 - Technical Feedback

Peer Reviewers: @Patton-Burge, @ASoledadU


You are missing a lot of type information in your code samples. Remember, all methods must specify argument and return types.


```java
class Richard {
twoDaughter();
}
class Aimee {
twoDaughter();
}
```
Once you find the similarities, you can break them up into a superclass:
```java
class Parents { // this is the superclass for the classes above it.
twoDaughter();
}
```
Once you create the superclass:
```java
class Aimee extends Parents {
System.out.println("Hello");
}
class Richard extends Parents {
System.out.println("World");
}
```

This code sample incorrectly suggests that you could just put statements like System.out.println(...); or twoDaughter(); inside the class definition.

A more appropriate sample might:

  • Define twoDaughter on the Richard and Aimee classes.

  • Move twoDaughter into the Parent class.

  • Redefine Richard and Aimee to inherit from Parent instead of defining twoDaughter.

  • Demonstrate using twoDaughter from a Richard or Aimee object.

  • @Patton-Burge verified fix

  • @ASoledadU verified fix


class Parent{
twoDaughter();
}
class Aimee extends Parent {
twoDaughter() {
// this is where you tell the method what to override it with.
}
}

The use statement calling twoDaughter inside Parent's definition is invalid. Parent should provide an initial definition, not attempt to call it.


Object has an Instance Variable and methods, but these are design to work with the class.

Objects can have multiple instance variables (gladiator.health and gladiator.rage).


```java
class Dog {
// instance variables
int x;
String breed;
String name;
void bark() { // a method
System.out.println("RUFF! RUFF!");
}
}
```
### Writing a tester (TestDrive) class: second step
``` java
class DogTestDrive {
public static void main(String[] args) {// main method
// Dog test code goes here;
}
}
```
In your tester, make an objects and access the object's variables and methods: third step
``` java
class DogTestDrive {
public static void main(String[] args) {
Dog d = new Dog(); //making this a dog object//
d.size = 40; // to set the size of the Dog
// use the dot operator (.)
d.bark(); // ad to call its bark() method
}
}

This section seems to have some formatting issues. Make sure that you are appropriately checking your output.


Neither of your sample applications demonstrate inheritance or overriding methods.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.