Coder Social home page Coder Social logo

year-11-cs-unit-6-quiz-dog's Introduction

Year-11-CS-Unit-6-Quiz-Dog

Ensure that you read all instructions carefully. Do not include any additional variables or methods that are not specified in this quiz description. Each question is worth one mark and is binary. That is, you either get 1 mark or 0 marks for each question (there are 13 questions on this quiz hence this quiz is worth 13 marks in total). The only application that is to be running on your computer is your IDE (until you are ready to submit your quiz). When you are ready to submit your quiz, please share it on github and ensure that all of your work has been pushed to your repository. Double check this by confirming that your completed classes exist in your repository on github. Submit the link to your repository on Schoology.

Good luck, have fun! :)

class Dog

  1. A Dog class will have four instance variables. Ensure that each instance variable is declared as private.
  • age (int)
  • name (String)
  • color (String)
  • owner (Owner)
  1. A Dog class will have one constructor.
  • The constructor will have four parameters. The four parameters will be used to initialize the four instance variables.
  1. A Dog class will have a getter method for each instance variable.
  2. A Dog class will have a setter method for each instance variable.
  3. A Dog class will have a private method called addOneAge that is parameterless and increments the age of the Dog.
  4. A Dog class will have a method called birthday that calls addOneAge and returns the age of the Dog.
  5. A Dog class will have a toString method that returns, for example, a String in the following format:
  • "The dog is named Marlo and is 5 years old. This dog is black." (Quotations are shown to represent that this is a string. The quotations do not need to be included in the returned String.)

class Owner

  1. An Owner class will have three instance variables. Ensure that each instance variable is declared as private.
  • firstName (String)
  • lastName (String)
  • phoneNumber (String)
  1. An Owner class will have one constructor.
  • The constructor will have three parameters. The three parameters will be used to initialize the three instance variables.
  1. An Owner class will have a getter method for each instance variable.
  2. An Owner class will have a setter method for each instance variable.

class DogMaker

Inside the main method ...

  1. Create an Owner object. The reference to this Owner object should be called owner. The firstName should be “John”, lastName “Wick”, phoneNumber “0800322520”.
  2. Create a Dog object. The reference to this Dog object should be called dog. The Dog's name should be Jill, age 2, colour black and tan. This should be done in a single statement.
  3. Use a setter method to change the Dog's name from Jill to Jessie.
  4. Use a getter method and print statement to print out the age of Jessie. Print out the age only, and use the println method to print. Do this using a single statement.
  5. Call the birthday method and store this into a variable called age.
  6. Print out the contents of the variable called age. Use the println method to print.
  7. Print out the current state of the Dog object. That is, print the reference to the Dog object. This will automatically call the toString method.

year-11-cs-unit-6-quiz-dog's People

Contributors

techarenz avatar gravo-lan avatar

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.