Giter Site home page Giter Site logo

comp1130-assignment2's Introduction

COMP1130 Assignment2

For this assignment we create a collection of fruit.

Objectives

  • Learn about Classes and Objects
  • Practice creating methods
  • Understand the difference between static and non-static vatiables
  • Practice using Git and GitHub to collaborate on projects

Instructions

  • Choose a fruit to create a class for. First check the list of pull requests to this repository to make sure nobody else has already picked the same fruit. Let's assume you picked apple. In this case you should create the class Apple.java and AppleDriver.java. Ofcourse your fruit will be a different one so name your classes according to this patten: Fruit.java and FruitDriver.java
  • In your version of Fruit.java class implement the following:
    • A private variable color which is a String type, and it's initial value is empty string ""
    • A static private variable called count which is initialized to 0
    • A private variable weight of type float which is initialized to 0.0
    • One constructor that accepts two values: color and weight and sets the private variables color and weight according to the input values
    • In the constructor increment the value of count by 1
    • A method called toString() that returns a statement such as this: "This instance of Apple is red and it is 0.55lb. So far you have created 3 apples"
  • Create the driver class with the name of your fruit. For example, if you picked Apple, your driver class should be called AppleDriver.java. In the driver class implement the following:
    • Create an instance of your fruit and print the result of it's toString() method
    • Create two more instances of your fruit and print the toString() output of the third instance

Submission

  • Fork this repository: https://github.com/arasbm/comp1130-assignment2
  • Clone your fork of the repository onto you computer (for example you can use GitHub Desktop for this)
  • Add your java files to the repository folder and complete them. Make sure to pick a fruit that is not picked by anyone else yet! The fruit names will be first come first serve. So the first pull request that picks a particular fruit is the only one that makes it into the repository
  • Make sure your Java files compile. Run and test your driver class
  • Commit your changes which should include exactly 2 Java file and no folders
  • Push your commits to your fork
  • When your changes are complete, go to your fork on GitHub and from there create a Pull Request to send your addition to the main repository here that you started with
  • Submit a link to your pull request on Moodle to complete the submission process

comp1130-assignment2's People

Contributors

arasbm avatar shynggystavbulatov 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.