联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp

您当前位置:首页 >> C/C++编程C/C++编程

日期:2020-02-09 10:29

CSCI 1730 Breakout / Lab 03

First Classes

Document Last Updated: February 3, 2020

Due: 2/9/2020 11:55 pm

This assignment is to be completed individually.

Introduction

This assignment will have you apply your knowledge of classes and objects in C++ to implement some basic.

General notes

You should not use pointers in this assignment.

Group brainstorm

There is one question for consideration in this assignment:

? What is the difference between pass-by-value and pass-by-reference?

Individual implementation

You are expected to complete this exercise individually.

1 Problem / Exercise

Account Class (account.cpp)

The account class will represent a simple bank account. You will implement the basic functionality, the internal representation,

and a few member functions.

The basic skeleton for your program is outlined below:

#include <iostream>

#include <cstdlib>

class Account {

public:

// add constructors here -- see description below

double getBalance() {

// add code here -- a basic getter

}

void setBalance(double balance) {

// add code here -- a basic setter

}

1

double deposit(double depositAmount) {

// your code should check to ensure that depositAmount is positive (e.g. deposit 100 dollars).

// It should only update the account balance if it is posotive.

// add code here

}

double withdraw(double withdrawalAmount) {

// This method should ensure that the withdrawalAmount is positive (e.g. withdraw 100 dollars).

// It should only update the account balance if the account can cover the withdrawal.

// add code here

}

double interest(double percent) {

// This method should accept percent (positive or negative). (e.g. to grow the account by 10%

// you would call interest(0.1). To decay the account by 20% you would call interest(-0.2))

// add code here

}

std::string getName() {

// add code here

}

void setName(std::string newName) {

// Your code should ensure that the name of the account has a max of 30 characters.

// If the newName passed to this function is longer than 30 characters, you should

// set the account name to be the first 30 characters of the argument.

// add code here

}

// write the transferTo method here -- see below

bool transferTo(double amount, Account otherAccount) {

// add code here

}

private:

// add more code here -- see description below

};

int main() {

// you should write code which tests the account class here.

return EXIT_SUCCESS;

}

constructor note: You should implement one constructor–a single argument constructor which takes the account name as

a parameter. This constructor will set the data member appropriately and the initial balance of the account to zero.

private notes: You should add whatever data members you need to implement this class in the private section of the

above code.

transferTo method. You should write a method called transferTo. Its first parameter should be a double ’amount’–the

amount to transfer. The second parameter should be the ’otherAccount’–the account to transfer the money to. note: You

2

might need to change the signature of the method. note: You should check that the account this method is called on has

enough funds to cover the transfer. If it does not, the transferTo method should return false. If the account does have

adequate funds, the money should be transferred to the ’otherAccount’ and the transferTo function should return true.

note: it is very important that you test this method from the main() method to ensure proper behavior. You might need

to change the method signature to get the expected behavior.

other notes: You may want to read up on std::string and bool values in c++ again.

2 Non-functional requirements

If your program does not compile on nike, then you’ll receive a grade of 0 on this assignment. Otherwise, your program will

will be graded using the criteria below.

It is important to note that your code will be run on several cases not listed in the examples section. Those cases should

not be taken to be a complete description of the way your program will be tested, rather they are to give you an idea of our

testing and the expected format of input and output. If you have any questions, please ask.

Your program will be compiled with the -std=c++11 -Wall and -pedantic-errors options enabled. You should ensure

that your program compiles without warnings and without errors with these options.

README file included 20 points

compilation without warnings/errors 20 points

correct program behavior on nike 60 points

Late Penalty -10 points for each 24 hour period late, nothing accepted after 48 hours late

You must test, test, and re-test your code to make sure it compiles and runs correctly on nike with any given set of valid

inputs. Your program’s I/O must match the examples given in the Examples section exactly.

3 Submission

Make sure you have a README!

Before your next breakout lab session, you need to submit your assignment. You will still be submitting your project via

Nike. Make sure your work is on nike.cs.uga.edu in a directory called LastName-FirstName-lab03. From within the

parent directory, execute the following command:

$ submit LastName-FirstName-lab03 cs1730

It is also a good idea to email a copy to yourself. To do this, simply execute the following command, replacing the email

address with your email address:

$ tar zcvf LastName-FirstName-lab03.tar.gz LastName-FirstName-lab03

$ mutt -s "lab03" -a LastName-FirstName-lab03.tar.gz -- your@email.com < /dev/null

3


版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp